Sail E0 Webinar
Question

What will be output if you compile following c code ?


#include<stdio.h>
typedef struct
{
int i;
float f;
}temp;
void alter(temp *ptr,int x, float y)
{
ptr->i=x;
ptr->f=y;
}
void main()
{
temp a={111,777.007};
printf("%d %.2f\n",a.i,a.f);
alter(&a,222,666.006);
printf("%d %.2f",a.i,a.f);
}




Options:
A .  Compile Error
B .  111 777.007 222 666.006
C .  111 777.01 222 666.01
D .  None of these
Answer: Option C

This program illustrates the transfer of a structure to a function by passing the structure's address (a pointer) to the function.




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers