Sample
Sample
________1. C99 standard guarantees uniqueness of ____ characters for internal names.
a) 31 c) 12
b) 63 d) 1
________2. Which of the following is not a valid variable name declaration?
a) 31 c) 12
b) 6 d) 4
________3. Which of the following is not a valid variable name declaration?
a) int a3; c) int A3;
b) int 3a; d) None of the mentioned
________4. Variable names beginning with underscore is not encouraged. Why?
a) It is not standardized
b) To avoid conflicts since assemblers and loaders use such names
c) To avoid conflicts since library routines use such names
d) To avoid conflicts with environment variables of an operating system
________5. Variable name resolving (number of significant characters for uniqueness of variable)
depends on
a) Compiler and linker implementations
b) Assemblers and loaders implementations
c) C language
d) None of the mentioned
________6. Which is valid C expression?
a) int my_num = 100,000; c) int my num = 1000;
b) int my_num = 100000; d) int $my_num = 10000;
________7. What is the output of this C code?
1. #
2. include < stdio.h > int main() {
3. int y = 10000;
4. int y = 34;
5. printf("Hello World! %d\n", y);
6. return 0;
7. }
a) Compile time error c) Hello World! 1000
b) Hello World! 34 d) Hello World! followed by a junk value
________8. Which of the following cannot be a variable name in C?
a) volatile c) friend
b) true d) export
________9. Which data type is most suitable for storing a number 65000 in a 32-bit system?
a) signed short c) long
b) unsigned short d) int
________10. What is the size of an int data type?
a) 4 Bytes c) Depends on the system/compiler
b) 8 Bytes d) Cannot be determined
________11. What is the output of this C code?
1. # include<stdio.h>
2. int main() {
3. signed char chr;
4. chr = 128;
5. printf("%d\n", chr);
6. return 0;
7. }
a) 128 c) Depends on the compiler
b) -128 d) None of the mentioned
________12. What is short int in C programming?
a) Basic datatype of C
b) Qualifier
c) Short is the qualifier and int is the basic datatype
d) All of the mentioned
________13. Comment on the output of this C code?
1. #include<stdio.h>
2. int main() {
3. float f1 = 0.1;
4. if (f1 == 0.1) printf("equal\n");
5. else printf("not equal\n");
6. }
a) equal c) output depends on compiler
b) not equal d) none of the mentioned
________14. Comment on the output of this C code?
1. #include < stdio.h >
2. int main() {
3. float f1 = 0.1;
4. if (f1 == 0.1 f) printf("equal\n");
5. else printf("not equal\n");
6. }
a) equal c) output depends on compiler
b) not equal d) none of the mentioned
________15. What is the output of this C code?
1. #include<stdio.h>
2. int main() {
3. int i = -5;
4. i = i / 3;
5. printf("%d\n", i);
6. return 0;
7. }
a) Implementation defined c) -3
b) -1 d) Compile time error
________16. What is the value of x in this C code?
1. # include < stdio.h >
2. void main() {
3. int x = 5 * 9 / 3 + 9;
4. }
a) 3.75 c) 24
b) Depends on compiler d) 3
________17. What is the output of this C code?
1. #include < stdio.h >
2. void main() {
3. int a = 3;
4. int b = ++a + a++ + --a;
5. printf("Value of b is %d", b);
6. }
a) Value of x is 12 c) Value of x is 10
b) Value of x is 13 d) Undefined behavior
________18. What is the output of this C code?
1. #include<stdio.h>
2. int main() {
3. int a = 10, b = 5, c = 5;
4. int d;
5. d = a == (b + c);
6. printf("%d", d);
7. }
a) Syntax error c) 10
b) 1 d) 5
________19. What is the output of this C code?
1. #include<stdio.h>
2. void main() {
3. int x = 1, y = 0, z = 5;
4. int a = x && y || z++;
5. printf("%d", z);
6. }
a) 6 c) 0
b) 5 d) Varies
________20. What is the output of this C code?
1. #include<stdio.h>
2. int main() {
3. int x = 1, y = 0, z = 3;
4. x > y ? printf("%d", z) : return z;
5. }
a) 3 c) Compile time error
b) 1 d) Run time error
________21. What is the output of this C code?
1. #include<stdio.h>
2. void main() {
3. int x = 1, z = 3;
4. int y = x << 3;
5. printf(" %d\n", y);
6. }
a) -2147483648 c) Run time error
b) -1 d) 8
________22. Comment on the output of this C code?
1. # include < stdio.h >
2. void main() {
3. float x = 0.1;
4. printf("%d, ", x);
5. printf("%f", x);
6. }
e) 0.100000, junk value g) 0, 0.100000
f) Junk value, 0.100000 h) 0, 0.999999
________23. When double is converted to float, the value is?
a) Truncated c) Depends on the compiler
b) Rounded d) Depends on the standard
________24. What is the output of this C code?
1. #include<stdio.h>
2. int main(){
3. unsigned int i = 23;
4. signed char c = -23;
5. if (i > c)
6. printf("Yes\n");
7. else if (i < c)
8. printf("No\n");
9. }
a) Yes c) Depends on the compiler
b) No d) Depends on the operating system
1. #include<stdio.h>
2. void main() {
3. int i = 2;
4. do {
5. printf("Hi");
6. } while (i < 2)
7. }
a) Compile time error c) Hi
b) Hi Hi d) Varies