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 tmp,int x,float y)
{
tmp.i=x;
tmp.f=y;
return tmp;
}
void main()
{
temp a={111,777.007};
printf("%d %.3f\n",a.i,a.f);
alter(&a,222,666.006);
printf("%d %.3f",a.i,a.f);
}




Options:
A .  Compile Error
B .  111 777.007222 666.006
C .  111 777.01222 666.01
D .  None of these
Answer: Option B

This program illustrates the transfer of a structure to a function by value. Also the altered structure is now returned directly to the calling portion of the program.




Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers