Sail E0 Webinar
Question

What will be output if you compile following c code ?


#include<stdio.h>
struct my_struct
{
int i=7;
float f=999.99;
}var;
void main()
{
var.i=5;
printf("%d %.2f",var.i,var.f);
}


Options:
A .  Compile error
B .  7 999.99
C .  5 999.99
D .  None of these
Answer: Option A

C language does not permit the initialization of individual structure members within the template. The initialization must be done only in the declaration of the actual variables.



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers