What will be output of the following c code? [code] #include<stdio.h> int main() { int a= sizeof(signed) +sizeof(unsigned); int

Nguyễn Hào

New member
What will be output of the following c code?
Code:
#include<stdio.h>
int main()
{
    int a= sizeof(signed) +sizeof(unsigned);
    int b=sizeof(const)+sizeof(volatile);
    printf("%d",a+++b);
    return 0;
}
A. 10
B. 9
C. 8
D. Error
 
Answer: c
Explanation: Default data type of signed, unsigned, const and volatile is intSo, a = 4 and b =4
Now, a+++b
= a++ + b
= 4 + 4 //due to post increment operator.
=8
But in Linux gcc compiler size of int is 4 byte so your out will be 16.
 

Tìm kiếm

Back
Top