Professional Documents
Culture Documents
MCQs of C
MCQs of C
A) [ ]
B) { }
C) ( )
D) None of the above
8. To accept 100 different values into the array we require
A) Loop
B) If condition
C) Function
D) Structure
9. If a is an integer variable, a=7/3; will return a value
A) 2.5
B) 3
C) 0
D) 2
10. Pointer holds
A) Value of variable
B) Address of variable
C) Value and address of variable
D) Always null
Answers:
1. C) Dennis Ritche
2. B) 8
3. D) All of the above
4. C) 15
5. B) A complier
6. D) Homogenous data type
7. C) ( )
8. A) Loop
9. D) 2
10. B) Address of variable
int age;
char name[30];
};
A) 30
B) 32
C) 34
D) 36
9. The expression x=4+2 % -8 evaluates to
A) -6
B) 6
C) 4
D) None of the above
10. A structure brings together a group of
A) items of the same data type
B) related data items and variables
C) integers with user defined names
D) floating points with user defined names
Answers:
1. B) is used first
2. A) Single address at a time
3. A) At least one digit
4. B) a=3, c=5
5. A) Blank Spaces
6. B) 1
7. A) Keywords variable names
8. C) 34
9. B) 6
10. B) related data items and variables
8. A compiler ................
A) is a computer program
B) translates a high level language into machine language
C) is a part of software
D) editor
9. Explicit type conversion is known as ....................
A) casting
B) conversion
C) disjunction
D) separation
10. A function popularly used C input function
A) scanf
B) printf
C) getch
D) Char
Answers:
A) 1970
4. Which escape character can be used to beep from speaker in C?
B) \b
5. Which of the following is a keyword is used for storage class?
C) auto
6. Continue statement is used .............
A) to go to the next iteration in a loop
7. File manipulation functions in C are available in which header file?
B) stdio.h
8. A compiler ................
B) translates a high level language into machine language
9. Explicit type conversion is known as ....................
A) casting
10. A function popularly used C input function
A) scanf
A) String.h
B) Strings.h
C) file.h
D) strcpy()
7. scanf() can be used for reading ...
A) double character
B) single character
C) multiple characters
D) no character
8. A variable which is visible only in the function in which it is defined is called
A) Static variable
B) auto variable
C) external variable
D) local variable
9. In the loop structure logical expression is checked at the ....................of the loop.
A) first
B) end
C) middle
D) second
10. If an array is used as function argument, the array is passed
A) by value
B) by reference
C) by name
D) the array cannot be used as function argument
11. If is necessary to declare the type of function in the calling program if
A) Function returns an integer
B) Function returns a non-integer value
C) Function is not defined in the same file
D) Function is called number of times
12. Which escape character can be used to begin a new line in C ........
A) \a
B) \m
C) \b
D) \n
13. Input/output function prototypes and macros are defined in which header file?
A) conio.h
B) stdlib.h
C) stdio.h
D) dos.h
14. What is the purpose of fflush() function?
A) flushes all streams and specified streams
B) flushes only specified stream
Answers:
B) 10
C) **
D) compilation error
2. Output of the following C program fragment is. x=5; y=x++; printf("%d %d", x,y);
A) 5, 6
B) 5, 5
C) 6, 5
D) 6, 6
3. What will be output of the following C program? #include int xyz=10; int main() { int xyz=20;
printf("%d", xyz); return 0;}
A) 10
B) 20
C) 30
D) compilation error
4. Following program fragment. main(){ printf("%p\n", main( ) ); }
A) Prints the address of main function
B) Prints 0
C) Is an error
D) In an infinite loop
5. What will be output of the following program? #include int main() {int a=2, b=7, c=10;
c=a==b; printf("%d",c); return 0;}
A) 0
B) 7
C) 10
D) 2
6. What is the output of the following program segment? main( ) { long i=65536; printf("%d\n",
i); }
A) 0
B) 65536
C) -1
D) 65
7. What will be the output of the program? # include int main() {int a[5]={5,1,15,20,25}; int i, j,
m; i=++a[1]; j=a[1]++; m=a[i++]; printf("%d, %d, %d", i,j,m); return0;}
A) 2, 1, 15
B) 1, 2, 5
C) 3, 2, 15
D) 2, 3, 20
8. What is the output of the following program segment? main( ) { int=1; do { printf("%d . . ", i);
} while (i--); }
A) 0 . . 1 . .
B) 1 . . 0 . .
C) 0
D) -1
9. Output of the program below is. int i; main( ) { printf("%d", i); }
A) 1
B) 0
C) -1
D) Null
10. What will be the output of the following program? main( ) { int i=5; printf("%d", i=+
+i==6); }
A) 0
B) 7
C) 6
D) 1
Answers:
1. What will be output of the following C program? #include int main() {int goto=5;
printf("%d",goto); return 0;}
A) 5
2. Output of the following C program fragment is. x=5; y=x++; printf("%d %d", x,y);
C) 6, 5
3. What will be output of the following C program? #include int xyz=10; int main() { int xyz=20;
printf("%d", xyz); return 0;}
B) 20
4. Following program fragment. main(){ printf("%p\n", main( ) ); }
A) Prints the address of main function
5. What will be output of the following program? #include int main() {int a=2, b=7, c=10;
c=a==b; printf("%d",c); return 0;}
A) 0
6. What is the output of the following program segment? main( ) { long i=65536; printf("%d\n",
i); }
A) 0
7. What will be the output of the program? # include int main() {int a[5]={5,1,15,20,25}; int i, j,
m; i=++a[1]; j=a[1]++; m=a[i++]; printf("%d, %d, %d", i,j,m); return0;}
C) 3, 2, 15
8. What is the output of the following program segment? main( ) { int=1; do { printf("%d . . ", i);
} while (i--); }
B) 1 . . 0 . .
9. Output of the program below is. int i; main( ) { printf("%d", i); }
B) 0
10. What will be the output of the following program? main( ) { int i=5; printf("%d", i=+
+i==6); }
D) 1
A) 0
B) 2
C) 1
D) 4
7. A C program contains the following declaration int i=8, j=5 what would be the value of
following expression? abs(i-2*j)
A) 2
B) 4
C) 6
D) 8
8. The output of the following is . int a=75; printf("%d%%", a);
A) 75
B) 75%%
C) 75%
D) None of the above
9. How many times the following program would print ("abc")? main( ) { printf("\nabc");
main( ); }
A) Infinite number of times
B) 32767 times
C) 65535 times
D) Till the stack does not overflow
10. Which of the following is the correct usage of conditional operators used in C?
A) a>b?c=30:c=40;
B) a>b?c=30;
C) max=a>b?a>c?a:c:b>c?b:c
D) return (a>b)?(a:b)
Answers: