Sail E0 Webinar
Question

What will be output if you compile following c code ?


#include<stdio.h>
struct first
{
int a;
float b;
}s1={32760,12345.12345};
typedef struct
{
char a;
int b;
}second;
struct my_struct
{
float a;
usigned int b;
};
typedef struct my_struct third;
void main()
{
struct second s2={'A',- -4};
third s3;
s3.a=~(s1.a-32760);
s3.b=-++s2.b;
printf("%d %.2f\n%c %d\n%.2f %u",(s1.a)--,s1.b+0.005,s2.a+32,s2.b,++(s3.a),--s3.b);
}


Options:
A .  Compile Error
B .  32760 12345.12 A 4 1 -5
C .  32760 12345.13 a -5 0.00 65531
D .  32760 12345.13 a 5 0.00 65530
Answer: Option D

 Illustrating 3 different ways of declaring the structres : first, second and third are the user-defined structure type. s1, s2 and s3 are structure variables. Also an expression of the form ++variable.member is equivalent to  ++(variable.member), i.e. ++ operator will apply to the structure member, not the entire structure variable.



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers