#include<stdio.h> int main() { char *s1; char far *s2; char huge *s3; printf("%d, %d, %d\n", sizeof(s1), sizeof(s2), sizeof(s3)); return 0; }
Since C is a compiler dependent language, it may give different output in other platforms. The above program works fine in Windows (TurboC), but error in Linux (GCC Compiler).
#include<stdio.h> int main() { int a[5] = {2, 3}; printf("%d, %d, %d\n", a[2], a[3], a[4]); return 0; }
#include<stdio.h> int main() { int i=5; for(;scanf("%s", &i); printf("%d\n", i)); return 0; }
Hence this for loop would get executed infinite times.
#include<stdio.h> int main() { extern int fun(float); int a; a = fun(3.14); printf("%d\n", a); return 0; } int fun(int aa) { return (int)++aa; }
#include<stdio.h> int X=40; int main() { int X=20; printf("%d\n", X); return 0; }
#include<stdio.h> int main() { extern int a; printf("%d\n", a); return 0; } int a=20;
printf("%d\n", a); it prints the value of local variable int a = 20. Because, whenever there is a conflict between local variable and global variable, local variable gets the highest priority. So it prints 20.
#include<stdio.h> int main() { int x = 10, y = 20, z = 5, i; i = x < y < z; printf("%d\n", i); return 0; }
#include<stdio.h> int main() { struct emp { char name[20]; int age; float sal; }; struct emp e = {"Tiger"}; printf("%d, %f\n", e.age, e.sal); return 0; }
#include<stdio.h> int main() { int X=40; { int X=20; printf("%d ", X); } printf("%d\n", X); return 0; }
#include<stdio.h> int main() { union a { int i; char ch[2]; }; union a u; u.ch[0] = 3; u.ch[1] = 2; printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i); return 0; }
So the output is 3, 2, 515.
1 : |
|
2 : |
|
3 : |
|
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.