Question
#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);
}
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);
}
Answer: Option C
Was this answer helpful ?
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 ?
Submit Solution