C Language Multiple Choice Questions And Answers - Basic Concepts

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;
       } 
  1. 3, 0, 0, 0
  2. 0, 3, 0.000000, 2.000000
  3. 0,0,0,0
  4. Error
Show/Hide Answer
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;
          }
  
  1. a = 22  b = -6
  2. a = -6  b = 22
  3. a =  3   b = 3
  4. No Output
Show/Hide Answer
Answer = A 
Explanation:No Explanation
3) 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);
                 return 0;
           } 
  1. 3
  2. 2
  3. Error
  4. None of above
Show/Hide Answer
Answer = C 
Explanation: Program will give the error : Illegal use of floating point. The statement 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;
       } 
  1. Nothing
  2. nn /n/n nn
  3. nn /n/n
  4. Error
Show/Hide Answer
Answer = B 
Explanation: No Explanation
5)  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;
         }
  1. a = 0  b = 0
  2. a = 1  b = 1
  3. Values you entered
  4. None of above
Show/Hide Answer
Answer = C 
Explanation: No Explanation
6) A character variable can at a time store  ?
  1. 1 character
  2. 8 character
  3. 254 character
  4. None of above
Show/Hide Answer
Answer = A 
Explanation: No Explanation
7) The maximum value that an integer constant can have is ?
  1. -32767
  2. 32767
  3. 1.7014e + 38
  4. -1.7014e + 38
Show/Hide Answer
Answer = B 
Explanation: The range of an integer number is -32767 - 32767
8)  Which of the following is false in C ?
  1. Keywords cannot be used as variable names
  2. Variable names can contain a digit
  3. Variable names do not contain a blank space
  4. Capital letters can be used in variable names
Show/Hide Answer
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 ?
  1. int variable
  2. float variable
  3. int constant
  4. All of above
Show/Hide Answer
Answer = B 
Explanation: No Explanation
10) A C variable cannot start with ?
  1. An alphabet
  2. A number
  3. A special symbol other that underscore
  4. Both B and C
Show/Hide Answer
Answer = D 
Explanation: No Explanation


Do You Like This? Please take 5 seconds to share with your firends.

1 comments:

Anonymous said...

Questions are very simple...you should increase the level of difficulty then it will be more helpful to students.

Post a Comment