Most questions of C-Language in Computer || Mock Test -01

Bhagat Education
0
computer-mock-test-01

Question 1: What will be the output of the following code?

int main()
{
    int i = 5;
    int a = --i + --i;
    printf("%d", a);
    return 0;
}
  1. (A) 8
  2. (B) 5
  3. (C) 7
  4. (D) 6

Question 2: What will be the output of the following code?

int main()
{
    int i = 5;
    int a = --i + --i + --i;
    printf("%d", a);
    return 0;
}
  1. (A) 8
  2. (B) 5
  3. (C) 7
  4. (D) 6

Question 3: What will be the output of the following code?

#include
int main()
{
    int num = 8;
    printf("%d %d", num << 1, num >> 1);
    return 0;
}
    
  1. (A) 7 9
  2. (B) 4 16
  3. (C) 9 7
  4. (D) 16 4

Question 4: What will be the output of the following code?

#include
int main()
{
    int i = 5;
    int a = ++i + ++i;
    printf("%d", a);
    return 0;
}
    
  1. (A) 14
  2. (B) 13
  3. (C) 12
  4. (D) 11

Question 5: What will be the output of the following code?

#include
int main()
{
    int i = 16;
    i =! i > 15;
    printf("i = %d", i);
    return 0;
}
    
  1. (A) 16
  2. (B) 1
  3. (C) 0
  4. (D) Compilation error

Question 6: What will be the output of the following code?

#include
int main()
{
    unsigned int num = -4;
    printf("%d", ~num);
    return 0;
}
    
  1. (A) Compilation error
  2. (B) 3
  3. (C) 4
  4. (D) some garbage value

Question 7: What will be the output of the following code?

#include
int main()
{
    int x = 2;
    (x & 1) ? printf("true") : printf("false");
    return 0;
}
    
  1. (A) Compilation error
  2. (B) true
  3. (C) false
  4. (D) Runtime error

Question 8: What will be the output of the following code?


int main()
{
    int a = 1, b = 3, c;
    c = b <<  a;
    b = c * (b * (++a)--);
    a = a >> b;
    printf("%d",b);
    return 0;
}
    
  1. (A) 36
  2. (B) Compilation error
  3. (C) 30
  4. (D) 24

Question 9: What will be the output of the following code?

#INCLUDE 
VOID MAIN()
{
    INT A=10;
    SWITCH(A){
        CASE 5+5:
        PRINTF("HELLO\n");
    DEFAULT:
    PRINTF("OK\n");
             }
   }
    
  1. (A) Hello
  2. (B) OK
  3. (C) Hello OK
  4. (D) Error

Question 10: What will be the output of the following code?

void main()
{
    int a=2;
    switch(a)
    {
        printf("Message\n");
        default:
            printf("Default\n");
        case 2:
            printf("Case-2\n");
        case 3:
            printf("Case-3\n");
    }
    printf("Exit from switch\n");
}
    
  1. (A) Case-2
  2. (B) Message
  3. (C) MessageCase-2
  4. (D) Case-2 Case-3 Exit from switch

Question 11: What will be the output of the following code?

void main()
{
    int a=2;
    switch(a/2*1.5)
    {
        case 1:
           printf("One...");
            break;
        case 2:
          printf("Two...");
           break;
        default:
        printf("Other...");
           break;
    }
}
    
  1. (A) One...
  2. (B) Two...
  3. (C) Other...
  4. (D) Error

Question 12: What will be the output of the following code?

#include <stdio.h>
void main()
{
    unsigned char var=0;
    for(var=0;var<=255;var++)
    {
        printf("%d ",var);
    }
}
    
  1. (A) 0 1 2 ... infinite times
  2. (B) 0 1 2 ... 255

Question 13: C IS _______ TYPE OF PROGRAMMING LANGUAGE.?

  1. A) OBJECT ORIENTED
  2. B) PROCEDURAL
  3. C) BIT LEVEL LANGUAGE
  4. D) FUNCTIONAL

Question 14: What will be the output of the following code?

#include <stdio.h>
void main()
{
    char cnt=0;
    for(;cnt++;printf("%d",cnt)) ;
    printf("%d",cnt);
}
    
  1. (A) 0 1 2 ... infinite times
  2. (B) 0 1 2 ... 127
  3. (C) 0
  4. (D) 1

Question 15: What will be the output of the following code?

#include <stdio.h>
void main()
{
    int cnt=1;
    do
    {
        printf("%d,",cnt);
        cnt+=1;
    } while(cnt>=10);
    printf("\nAfter loop cnt=%d",cnt);
    printf("\n");
}
    
  1. (A) After loop cnt=1
  2. (B) 1,After loop cnt=2
  3. (C) After loop cnt=2

Question 16: What will be the output of the following code?

#include <stdio.h>
#define TRUE 1
int main()
{
    int loop=10;
    while(printf("Hello ") && loop--);
}
    
  1. (A) Hello
  2. (B) Hello Hello Hello Hello ... (Infinite times)
  3. (C) Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello (10 times)
  4. (D) Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello (11 times)

Question 17: What will be the output of the following code?

#include <stdio.h>
int main()
{
    int i=1;
    while(i<=10 && 1++)
        printf("Hello");
}
    
  1. (A) Error: lvalue required as increment operand
  2. (B) HelloHello ... 10 times
  3. (C) HelloHello ... 11 times
  4. (D) Hello

Question 18: INT MAIN() HOW MANY TIMES THIS LOOP WILL EXECUTE?

{
    INT I;
    FOR(I=0;I<10 0="" code="" i="++I;" n="" printf="" return="">
  1. (A) 10
  2. (B) 5
  3. (C) 4
  4. (D) NONE OF THESE

Question 19: WHICH OF THE FOLLOWING SENTENCES ARE CORRECT ABOUT A FOR LOOP IN A C PROGRAM?

  1. A) FOR LOOP WORKS FASTER THAN A WHILE LOOP.
  2. B) ALL THINGS THAT CAN BE DONE USING A FOR LOOP CAN ALSO BE DONE USING A WHILE LOOP.
  3. C) FOR(;;); IMPLEMENTS AN INFINITE LOOP.
  4. D) FOR LOOP CAN BE USED IF WE WANT STATEMENTS IN A LOOP GET EXECUTED AT LEAST ONCE.

Question 20: A CHAR VARIABLE CAN STORE EITHER AN ASCII CHARACTER OR A UNICODE CHARACTER.

  1. A. TRUE
  2. B. FALSE

Question 21: HIGHT LEVEL LANGUAGE IS A?

  1. A) HUMAN READABLE LIKE LANGUAGE.
  2. B) LANGUAGE WITH SMALL PROGRAM SIZE.
  3. C) LANGUAGE WITH BIG PROGRAM SIZE.
  4. D) LANGUAGE WHICH IS DIFFICULT TO UNDERSTAND AND NOT HUMAN READABLE.

Question 22: C IS _______ TYPE OF PROGRAMMING LANGUAGE.?

  1. A) OBJECT ORIENTED
  2. B) PROCEDURAL
  3. C) BIT LEVEL LANGUAGE
  4. D) FUNCTIONAL

Question 23: CHOOSE CORRECT STATEMENTS

  1. A) A CONSTANT VALUE DOES NOT CHANGE. A VARIABLE VALUE CAN CHANGE ACCORDING TO NEEDS.
  2. B) A CONSTANT CAN CHANGE ITS VALUES. A VARIABLE CAN HAVE ONE CONSTANT VALUE ONLY.
  3. C) THERE IS NO RESTRICTION ON NUMBER OF VALUES FOR CONSTANTS OR VARIABLES.
  4. D) CONSTANTS AND VARIABLES CAN NOT BE USED IN A SINGLE MAIN FUNCTION.

Question 24: FIND A CORRECT C KEYWORD BELOW.

  1. A) BREAKER
  2. B) GO TO
  3. C) SHORTER
  4. D) DEFAULT

Question 25: FIND A CORRECT C KEYWORD BELOW.

  1. A) WORK
  2. B) CASE
  3. C) CONSTANT
  4. D) PERMANENT

Post a Comment

0Comments

Post a Comment (0)