# Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 128 - 129 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

## Question 128

C & C Plus Plus
Edit

### Write in Short

What is the output of the following program?

`struct point{int x;int y;};struct point origin,⚹pp;main(){pp=&origin;printf("origin is(%d%d)",(⚹pp).x,(⚹pp).y);printf("origin is (%d%d)",pp → x,pp → y);}`

### Explanation

• In the program int x; int y; Structure pointer is globally declared with x and y. pp = &origin; pp is a pointer to structure. printf ( “origin is (% d % d) ” , (⚹ pp) . x, (⚹ pp) . y) ; printf ( “origin is (% d % d) ” , pp ⇾ x, pp ⇾ y) ; We can access the elements ofthe structure either with arrow mark or with indirection operator.Since structure point is globally declared x & y are initialized as zeroes
• So, the answer is origin is (0,0) origin is (0,0) .

## Question 129

C & C Plus Plus
Edit

### Describe in Detail

Essay▾

Predict the output or error (s) for the following:

1. `#include<stdio.h>`
2. `main ()`
3. `{`
4. `    char ⚹str =“hello”;`
5. `    char ⚹ptr =str;`
6. `    char least =127;`
7. `    while (⚹ptr++)`
8. `    least =⚹ptr;`
9. `    printf ( “%d”,least);`
10. `}`

### Explanation

In the program

 char ⚹ str = “hello” ; Define character pointer str = hello char ⚹ ptr = str; After ‘ptr’ reches the end of the string the value pointed by ‘str’ is ‘⧵0’ . char least = 127; Given the character variable least = 127 while (⚹ ptr ++) The value of ‘str’ is less than that of ‘least’ least =⚹ ptr; The value of ‘least’ is store the ⚹ ptr value printf ( “% d” , least) ; So the value of ‘least’ is 0.

Developed by: