Question 1
#include<stdio.h> int main() { unsigned int x = -1; int y = ~0; if (x == y) printf("same"); else printf("not same"); return 0; }
Question 2
1. short int x;
2. signed short x;
3. short x;
4. unsigned short x;
Question 3
#include <stdio.h> int main() { float c = 5.0; printf ("Temperature in Fahrenheit is %.2f", (9/5)*c + 32); return 0; }
Question 4
Predict the output of following C program
#include <stdio.h> int main() { char a = 012; printf("%d", a); return 0; }
Compiler Error
12
10
Empty
Question 6
int main() { void *vptr, v; v = 0; vptr = &v; printf("%v", *vptr); getchar(); return 0; }
Question 7
#include<stdio.h> int main() { char c = 125; c = c+10; printf("%d", c); return 0; }
Question 8
#include <stdio.h> int main() { if (sizeof(int) > -1) printf("Yes"); else printf("No"); return 0; }
Question 9
#include<stdio.h> int main() { float x = 0.1; if ( x == 0.1 ) printf("IF"); else if (x == 0.1f) printf("ELSE IF"); else printf("ELSE"); }
Question 10
Suppose n and p are unsigned int variables in a C program. We wish to set p to nC3. If n is large, which of the following statements is most likely to set p correctly?
p = n * (n-1) * (n-2) / 6;
p = n * (n-1) / 2 * (n-2) / 3;
p = n * (n-1) / 3 * (n-2) / 2;
p = n * (n-1) * (n-2) / 6.0;
There are 14 questions to complete.