Question
#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);
}
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);
}
Answer: Option B
Was this answer helpful ?
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 ?
More Questions on This Topic :
Question 2.
How will you free the allocated memory ?
....
Submit Solution