Question
#include<stdio.h>
struct
{
int i,val[25];
float f;
}var={1,2,3,4,5,6,7,8,9},*vptr=&var;
void main()
{
printf("%d %d %d\n",var.i,vptr->i,(*vptr).i);
printf("%d %d %d %d %d %d",var.val[4], var.val+4), vptr->val[4],*(vptr->val+4),
(*vptr).val[4], *((*vptr).val+4));
}
What will be output if you compile following c code ?
#include<stdio.h>
struct
{
int i,val[25];
float f;
}var={1,2,3,4,5,6,7,8,9},*vptr=&var;
void main()
{
printf("%d %d %d\n",var.i,vptr->i,(*vptr).i);
printf("%d %d %d %d %d %d",var.val[4], var.val+4), vptr->val[4],*(vptr->val+4),
(*vptr).val[4], *((*vptr).val+4));
}
Answer: Option B
Was this answer helpful ?
Since value of the member 'i' can be accessed using var.i, vptr->i and (*vptr).i Similarly 5th value of the member 'val' can be accessed using var.val[4], *(var.val+4), vptr->val[4], *(vptr->val+4), (*vptr).val[4] and *((*vptr).val+4)
Was this answer helpful ?
Submit Solution