Multiple choice questions and answers with explanation on C language. The questions are based on the basic concepts of C language like keywords, Expressions etc. 1) What will be the output of following program ? #include int main( ) { int i=2,j=3,k,l; float a,b; k = i/j * j; l = j/i * j; a = i/j * j; b = j/i * i; printf("%d %d%f%f\n",k,l,a,b); return 0; } a. b. c. d.
3, 0, 0, 0 0, 3, 0.000000, 2.000000 0,0,0,0 Error Answer = B Explanation: As K and L are integer variables so it prints the integer value as result and a and b are float variable, so float value will be print as result. 2) What will be the output of following program ? #incllude int main( ) { int a,b; a = -3 - - 25; b = -3 - - (-3); printf("a=%d b=%d\n",a,b); return 0; }
a. b. c. d.
a = 22 b = -6 a = -6 b = 22 a= 3 b=3 No Output Answer = A Explanation:No Explanation 3) What will be the output of following program ? #include int main( ) {
float a=5,b=2; int c,d; c =a%d; d =a/2; printf("%d\n",d); return 0; } a. b. c. d.
3 2 Error None of above Answer = C Explanation: Program will give the error : Illegal use of floating point. Thestatement c = a%b will give the error. 4) What will be the output of program ? #include int main( ) { printf("nn /n/n nn/n"); return 0; }
a. b. c. d.
Nothing nn /n/n nn nn /n/n Error Answer = B Explanation: No Explanation 5) What will be the output of program ? #include int main( ) { int a,b; printf("Enter two values of a and b"); scanf("%d%d",&a,&b); printf("a=%d b=%d"a,b); return 0; }
a. b. c. d.
a =0 b =0 a =1 b =1 Values you entered None of above Answer = C Explanation: No Explanation
6) A character variable can at a time store ? a. b. c. d.
1 character 8 character 254 character None of above Answer = A Explanation: No Explanation 7) The maximum value that an integer constant can have is ?
a. b. c. d.
-32767 32767 1.7014e + 38 -1.7014e + 38 Answer = B Explanation: The range of an integer number is -32767 - 32767 8) Which of the following is false in C ?
a. b. c. d.
Keywords cannot be used as variable names Variable names can contain a digit Variable names do not contain a blank space Capital letters can be used in variable names Answer = A Explanation: Keywords can be used as variable names but by doing this it creates confusion 9) On which if the following operator can % operator NOT be used ?
a. b. c. d.
int variable float variable int constant All of above Answer = B Explanation: No Explanation 10) A C variable cannot start with ?
a. b. c. d.
An alphabet A number A special symbol other that underscore Both B and C Answer = D Explanation: No Explanation
1) Which of the following is not true in context of C language ? a. It is array of characters b. Last character of character array is always \0
c. C inserts the null character automatically d. Any string in C can be read by the function getchar() Answer = B and C Explanation: No Explanation 2) Which of the following operations can not be perform on pointers in C ? a. b. c. d.
Addition of two pointers Subtraction of a number from a pointer Subtraction of one pointer from another Addition of a number to a pointer Answer = A Explanation: No Explanation 3) What will be the output of following program ? main( ) { static char a[]="BOMBAY" char *b="BOMBAY"; printf("\n%d%d",size of(a),size of (b)); }
a. b. c. d.
a=7, b=7 a=7, b=2 a=2, b=7 a=7, b=0 Answer = C Explanation: No Explanation 4) What is the output of C statement 7.5 % 3 ?
a. b. c. d.
1.5 1 No output Error Answer = D Explanation: No Explanation 5) Any program in C has access to three standard files?
a. b. c. d. e.
standard input file, standard output file, standard error f ile stdin, stdout, stderr keywords, screen, stderr All of above None of above Answer = B Explanation: No Explanation 6) An identifier in C ?
a. is a name of thing such as variable and function
b. c. d. e.
is made up of letters, numerals and the underscore can contain both uppercase and lowercase letters All of above None of above Answer = D Explanation:No Explanation 7) The single character input/output functions are ?
a. b. c. d. e.
scanf( ) and printf( ) getchar( ) and printf( ) scanf( ) and putchar( ) getchar( ) and putchar( ) None of above Answer = D Explanation: No Explanation 8) Precedence determines which operator ?
a. b. c. d. e.
is evaluated first is most important is fastest Operates on the largest number None of above 9) In C, the NULL statement which does nothing is just ?
a. b. c. d.
a., ; : . Answer = B Explanation:No Explanation 10) The two operators && and || are ?
a. b. c. d. e.
arithmetic operators equality operators logical operators relational operators None of above Answer = D Explanation: No Explanation
1) The Conditional Compilation ? a. It is taken care of by the compiler b. It is setting the compiler options conditionally
c. It is compiling a program based on condition d. None of Above Answer = C
2) Originally C was developed as ? a. b. c. d.
System Programming Language General Purpose Language Data Processing Language None of Above Answer = A 3) Minimum number of temporary variable needed to swap the contents of 2 v ariable is ?
a. b. c. d.
1 2 3 0 Answer =D
4)*ptr++ is equivalent to ? a. b. c. d.
ptr++ *ptr ++*ptr None of Above Answer = D 5) Expression C=i++ Causes ?
a. b. c. d.
Value of i is assigned to C and then I is incremented by 1 i to be incremented by 1, and then value of i assigned to C Value of i assigned to C i to be incremented by 1 Answer = A
6) Declaration int *(*p) int(*a)(i) is ? a. b. c. d.
A pointer to function that accepts an integer argument and returns an integer A pointer to a, which returns an integer A pointer to subroutine, which returns result of evaluation None of Above Answer = A 7) Null pointer and UN-initialized pointers are same ?
a. True b. False
c. Varies from program to program d. None of Above Answer = B 8) In which header file Null macro is defined ? a. b. c. d.
stdio.h and stddeth Iostream.h string.h preprocessor Answer = A 9) Null pointer is ?
a. b. c. d.
A pointer which does not point anywhere Pointer defined with name Null A pointer that returns 0 values None of Above Answer = A 10) Null macro is ?
a. b. c. d.
A macro with name Null A macro which represents Null pointer A macro defined with no name None of Above Answer = B