Share
C Programming MULTIPLE CHOICE QUESTIONS

SponsoredAdvertise

1.

Which of the following is not a valid variable name declaration?

A.

int _a3;

B.

int a_3;

C.

int 3_a;

D.

int _3a;

2.

Which of the following is true for variable names in C?

A.

They can contain alphanumeric characters as well as special characters

B.

It is not an error to declare a variable to be one of the keywords(like goto, static)

C.

Variable names cannot start with a digit

D.

Variable can be of any length

3.

Which is valid C expression?

A.

int my_num = 100,000;

B.

int my_num = 100000;

C.

int my num = 1000;

D.

int $my_num = 10000;

4.

What will be the output of the following C code?


#include 
int main()
{
        printf("Hello World! %d \n", x);
        return 0;
}

A.

Hello World! x;

B.

Hello World! followed by a junk value

C.

Compile time error

D.

Hello World!

5.

What will be the output of the following C code?


#include 
 int main()
 {
        int y = 10000;
        y = 34;
        printf("Hello World! %d\n", y);
        return 0;
}

A.

Compile time error

B.

Hello World! 34

C.

Hello World! 1000

D.

Hello World! followed by a junk value

6.

What will be the output of the following C code?


#include 
 int main()
 {
        int m = 3;
        printf("%d", m);
        return 0;
 }

A.

It will cause a compile-time error

B.

It will cause a run-time error

C.

It will run without any error and prints 3

D.

It will experience infinite looping

7.

A ...... translates a high-level language program into a machine language.

A.

translator

B.

compiler

C.

memory

D.

code editor

8.

Which of the following functions is used to display information on the screen?

A.

scanf

B.

printf

C.

placeholder

D.

header

9.

Which of the following functions is used to get an input from a user?

A.

scanf

B.

printf

C.

placeholder

D.

header

10.

What will be the function prototype for the function below:


double mult(double a, double b){
         return a * b;
}

A.

mult(a,b);

B.

double mult(a,b);

C.

double mult(double, double);

D.

double mult(double a, double b){}

11.

What will be the output of the following C code?


#include 
 void main()
 {
        int x = 5;
        if (x < 1){
            printf("hello");
        }
        if (x == 5){
           printf("hi");
       }else{
          printf("no");
       }
}

A.

hi

B.

hello

C.

no

D.

error

12.

What will be the output of the following C code?


#include 
 void main()
 {
        int x = 4;
        if (x < 1){
            printf("Hello");
        }
 
 }

A.

Nothing

B.

Run time error

C.

Hello

D.

Varies

13.

What will be the output of the following C code?


#include 
 void main()
 {
        int x = 0;
        if (x < 1){
            printf("Hello");
        }
 
 }

A.

Hello

B.

Run time error

C.

Nothing

D.

Varies

14.

What will be the appropriate data type for an input of 2.5?

A.

int

B.

float or double

C.

char

D.

none

15.

What will be the appropriate data type for an integer input value?

A.

int

B.

char

C.

float

D.

double

16.

What will be the appropriate data type for a single character input?

A.

char

B.

int

C.

float

D.

double

17.

Which of the following is a placeholder for the int data type?

A.

%f

B.

%c

C.

%i

D.

%d

18.

Which of the following is a placeholder for the char data type?

A.

%c

B.

%d

C.

%lf

D.

%f

19.

Which of the following is a placeholder for the double data type?

A.

%lf

B.

%c

C.

%s

D.

%d

20.

What will be the output of the following C code?


#include 
#include 

int main()
{
    int i = 5%2;
    printf("i = %d",i);
    return 0;
}

A.

i = 2.5

B.

i = 1

C.

1

D.

2.5

21.

Which of the following is a logical OR operator?

A.

&

B.

&&

C.

||

D.

None of the above

22.

What will be the output of the following C code?


#include 
#include 

int main()
{
    int i = 8;
    switch(i%3){
        case 0:
            printf("Result: 0");
            break;
        case 1:
            printf("Result: 1");
            break;
        case 2:
            printf("Result: 2");
            break;
        case 3:
            printf("Result: 3");
            break;
        default:
            printf("None");
    }
    return 0;
}

A.

Result 0

B.

Result 1

C.

Result 2

D.

Result 3

23.

What will be the output of the following C code?


#include 
#include 

int main()
{
    int i = 8;
    do{
        printf("%d\n",i);
        i++;
    }while(i<5);
    return 0;
}

A.

Nothing

B.

8

C.

1
2
3
4

D.

8
7
6

24.

What will be the output of the following C code?


#include 
#include 

int main()
{
    int i = 8;
    while(i<5){
        printf("%d\n",i);
        i++;
    }
    return 0;
}

A.

8

B.

1
2
3
4

C.

8
7
6

D.

Nothing

25.

Which of the following is not a loop?

A.

for

B.

while

C.

do while

D.

switch

26.

What will be the output of the following C code?


#include 
#include 

int main()
{
    int i = 8;
    i++;
    printf("%d\n",i);
    return 0;
}

A.

8

B.

7

C.

9

D.

6

27.

What will be the output of the following C code?


#include 
#include 

int main()
{
    int i = 8;
    i--;
    printf("%d\n",i);
    return 0;
}

A.

8

B.

9

C.

7

D.

6

28.

What will be the output of the following C code?


#include 
#include 

int main()
{
    int a = 3;
    int i;
    for(i=0;i<5;i++){
        printf("%d ",i*a);
    }
    return 0;
}

A.

0 1 2 3 4

B.

0 3 6 9 12

C.

3

D.

Nothing

29.

What will be the output of the following C code?


#include 
#include 

int main()
{
    int i;
    for(i=0;i<5;i++){
        printf("*");
    }
    return 0;
}

A.

*

B.

**

C.

***

D.

*****

30.

Which of the following is a logical AND operator?

A.

&

B.

&&

C.

||

D.

None of the above

SponsoredAdvertise