C Programming - Complicated Declarations - Discussion
Discussion Forum : Complicated Declarations - Find Output of Program (Q.No. 5)
5.
What will be the output of the program?
#include<stdio.h>
typedef void v;
typedef int i;
int main()
{
v fun(i, i);
fun(2, 3);
return 0;
}
v fun(i a, i b)
{
i s=2;
float i;
printf("%d,", sizeof(i));
printf(" %d", a*b*s);
}
Discussion:
19 comments Page 1 of 2.
Saket said:
1 decade ago
Can anybody please explain when we declare float int; it will give an error but when we use typedef int I then float i; does not give an error why?
Ashok said:
7 years ago
Float variable takes 4bytes and the remaining statement will be computed as a*b*s=2*3*2=12 first statement it will print size and then computation.
Shyam said:
8 years ago
Hi, please explain the 3 bit which is given to b.
Ajay said:
8 years ago
The float i is local variable so it has max priority than typedef int i which is global variable.
Prakash gautam said:
8 years ago
The typedef int i is global and float i is local and local variable has more priority in function.
Prakash gautam said:
8 years ago
Here i is in sizeof is from float i not from typedef you can check it by taking char i instead of float i than find the sizeof(i) it will give 1.
Udhaya said:
9 years ago
typedef void i means? Anyone explain me.
Neha said:
9 years ago
Please, anybody explain the value of i.
LAVANYA said:
10 years ago
Can you explain this I can't understand?
Sunil said:
1 decade ago
i is declared as float.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers