#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.
#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() { 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 = 10, y = 20, z = 5, i; i = x < y < z; printf("%d\n", i); return 0; }
#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; }
1 : |
|
2 : |
|
3 : |
|
1 : | typedef long a; extern int a c; |
2 : | typedef long a; extern a int c; |
3 : | typedef long a; extern a c; |
typedef long a;
extern a int c; while compiling this statement becomes extern long int c;. This will result in to "Too many types in declaration error".
typedef long a;
extern a c; while compiling this statement becomes extern long c;. This is a valid c declaration statement. It says variable c is long data type and defined in some other file or module.
So, Option C is the correct answer.
int i = 35; i = i%5;
short int j = 255; j = j;
long int k = 365L; k = k;
float a = 3.14; a = a%3;
float a = 3.14; a = a%3;
The modulus (%) operator can only be used on integer types. We have to use fmod() function in math.h for float values.
1 : |
|
2 : |
|
3 : |
|
char int; here int is a keyword cannot be used a variable name.
int long; here long is a keyword cannot be used a variable name.
float double; here double is a keyword cannot be used a variable name.
So, the answer is int length;(Option A).
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.