7
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<stdio.h> 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. 3, 0, 0, 0 b. 0, 3, 0.000000, 2.000000 c. 0,0,0,0 d. 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<stdio.h> int main( ) { int a,b; a = -3 - - 25; b = -3 - - (-3); printf("a=%d b=%d\n",a,b); return 0; } a. a = 22 b = -6 b. a = -6 b = 22 c. a = 3 b = 3 d. No Output Answer = A Explanation:No Explanation

Multiple Choice Questions c Language

Embed Size (px)

DESCRIPTION

c language mcqs

Citation preview

Page 1: Multiple Choice Questions c Language

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<stdio.h>       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. 3, 0, 0, 0b. 0, 3, 0.000000, 2.000000c. 0,0,0,0d. Error

Answer = BExplanation: 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<stdio.h>          int main( )          {              int a,b;              a = -3 - - 25;              b = -3 - - (-3);              printf("a=%d b=%d\n",a,b);              return 0;          }    

a. a = 22  b = -6b. a = -6  b = 22c. a =  3   b = 3d. No Output

Answer = A Explanation:No Explanation3) What will be the output of following program ?           #include<stdio.h>           int main( )           {                  float a=5,b=2;                 int c,d;                 c =a%d;                 d =a/2;                 printf("%d\n",d);

Page 2: Multiple Choice Questions c Language

                 return 0;           }  

a. 3b. 2c. Errord. 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<stdio.h>       int main( )       {           printf("nn /n/n nn/n");           return 0;       }  

a. Nothingb. nn /n/n nnc. nn /n/nd. Error

Answer = B Explanation: No Explanation5)  What will be the output of program ?         #include<stdio.h>         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. a = 0  b = 0b. a = 1  b = 1c. Values you enteredd. None of above

Answer = C Explanation: No Explanation6) A character variable can at a time store  ? 

a. 1 characterb. 8 characterc. 254 characterd. None of above

Answer = A Explanation: No Explanation7) The maximum value that an integer constant can have is ? 

a. -32767

Page 3: Multiple Choice Questions c Language

b. 32767c. 1.7014e + 38d. -1.7014e + 38

Answer = B Explanation: The range of an integer number is -32767 - 327678)  Which of the following is false in C ? 

a. Keywords cannot be used as variable namesb. Variable names can contain a digitc. Variable names do not contain a blank spaced. Capital letters can be used in variable names

Answer = A Explanation: Keywords can be used as variable names but by doing this it creates confusion9) On which if the following operator can % operator NOT be used ? 

a. int variableb. float variablec. int constantd. All of above

Answer = B Explanation: No Explanation10) A C variable cannot start with ? 

a. An alphabetb. A numberc. A special symbol other that underscored. 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 charactersb. Last character of character array is always \0c. C inserts the null character automaticallyd. Any string in C can be read by the function getchar()

Answer =  B and CExplanation: No Explanation 2)  Which of the following operations can not be perform on pointers in C ? 

a. Addition of two pointersb. Subtraction of a number from a pointerc. Subtraction of one pointer from anotherd. Addition of a number to a pointer

Answer = AExplanation: No Explanation3) What will be the output of following program ?             main( )            {                   static char a[]="BOMBAY"

Page 4: Multiple Choice Questions c Language

                   char *b="BOMBAY";                   printf("\n%d%d",size of(a),size of (b));            }  

a. a=7, b=7b. a=7, b=2c. a=2, b=7d. a=7, b=0

Answer = CExplanation: No Explanation4) What is the output of  C statement 7.5 % 3 ? 

a. 1.5b. 1c. No outputd. Error

Answer = DExplanation: No Explanation 5) Any program in C has access to three standard files? 

a. standard input file, standard output file, standard error fileb. stdin, stdout, stderrc. keywords, screen, stderrd. All of abovee. None of above

Answer = B Explanation: No Explanation 6) An identifier in C  ? 

a. is a name of thing such as variable and functionb. is made up of letters, numerals and the underscorec. can contain both uppercase and lowercase lettersd. All of abovee. None of above

Answer = DExplanation:No  Explanation 7) The single character input/output functions are  ? 

a. scanf( ) and printf( )b. getchar( ) and printf( )c. scanf( ) and putchar( )d. getchar( ) and putchar( )e. None of above

Answer = DExplanation: No Explanation 8) Precedence determines which operator ? 

a. is evaluated firstb. is most importantc. is fastest d. Operates on the largest number

Page 5: Multiple Choice Questions c Language

e. None of above9) In C, the NULL statement which does nothing is just ? 

a. a.,b. ;c. :d. .

Answer = BExplanation:No Explanation 10) The two operators && and || are ? 

a. arithmetic operatorsb. equality operatorsc. logical operatorsd. relational operatorse. None of above

Answer = D Explanation: No Explanation 

1) The Conditional Compilation  ? 

a. It is taken care of by the compilerb. It is setting the compiler options conditionallyc. It is compiling a program based on conditiond. None of Above

Answer = C 

2) Originally C was developed as ? 

a. System Programming Languageb. General Purpose Languagec. Data Processing Languaged. None of Above

Answer = A3) Minimum number of temporary variable needed to swap the contents of 2 variable is ? 

a. 1b. 2c. 3d. 0

Answer =D

4)*ptr++ is equivalent to ? 

a. ptr++b. *ptrc. ++*ptrd. None of Above

Answer =  D

Page 6: Multiple Choice Questions c Language

5) Expression C=i++ Causes ? 

a. Value of i is assigned to C and then I is incremented by 1b. i to be incremented by 1, and then value of i assigned to Cc. Value of i assigned to Cd. i to be incremented by 1

Answer = A

6) Declaration int *(*p) int(*a)(i) is ? 

a. A pointer to function that accepts an integer argument and returns an integerb. A pointer to a, which returns an integerc. A pointer to subroutine, which returns result of evaluationd. None of Above

Answer = A7) Null pointer and UN-initialized pointers are same ? 

a. Trueb. Falsec. Varies from program to programd. None of Above

Answer = B8) In which header file Null macro is defined ? 

a. stdio.h and stddethb. Iostream.hc. string.hd. preprocessor

Answer = A 9) Null pointer is ? 

a. A pointer which does not point anywhereb. Pointer defined with name Nullc. A pointer that returns 0 valuesd. None of Above

Answer = A10) Null macro is ? 

a. A macro with name Nullb. A macro which represents Null pointerc. A macro defined with no named. None of Above

Answer = B