# Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 90 - 91 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 90

C & C Plus Plus
Edit

### Write in Short

Is the following code legal?

1. `struct a`
2. `{`
3. `    int x;`
4. `    struct a ⚹b;`
5. `}`

### Explanation

In this code

 struct a{int x;struct a ⚹ b;} ⚹ b is a pointer to type struct a and so it is legalThe compiler knows, the size of the pointer to a structure even before the size of the structure is determinedThe pointer to any type is of same size.This type of structures is known as ‘self-referencing’ structure.

## Question 91

C & C Plus Plus
Edit

### Describe in Detail

Essay▾

What is the output of the following program?

1. `main ()`
2. `{`
3. `    char a[100];`
4. `    a[0] =‘a’ a[1] =‘b’ a[2] =‘c’ a[4] =‘d’ ;`
5. `    abc (a);`
6. `}`
7. `abc (char a[])`
8. `{`
9. `    a ++;`
10. `    printf ( “%c” ⚹a);`
11. `    a ++;`
12. `    printf ( “%c” ⚹a);`
13. `}`

### Explanation

In the program

 char a [100] ; Declare the character array a [100] ; a [0] = ‘a’ a [1] = ‘b’ a [2] = ‘c’ a [4] = ‘d’ ; Define the characters in the array. abc (a) ; Applying abc (a) function abc (char a [] ){a ++ ;printf ( “% c” ⚹ a) ;a ++ ;printf ( “% c” ⚹ a) ;} In the abc () functionFirst the base address is modified only in function and as a result ‘a’ points to ‘b’ then after incrementing to ‘c’ .So, bc will be printed.

Developed by: