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);
}
2, 8
4, 8
2, 4
4, 12
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
19 comments Page 1 of 2.

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.

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?


Post your comments here:

Your comments will be displayed after verification.