wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Day 3 C Programming quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which conversion is not possible in c programming?

a)

int to float

b)

float to char pointer

c)

float to int

d)

All of these

2.

Which header file is needed to include to use typecasting?

a)

stdin.h

b)

math.h

c)

ctype.h

d)

None

3.

#include<stdio.h>

int main()

{

double x = 1.2;

int sum = (int)x + 1;

printf("sum = %d", sum);

return 0;

}

what will be the value of the variable sum?

a)

1

b)

2

c)

3

d)

0

4.

Which type of conversion is also called Automatic Type Conversion?

a)

Implicit Type Conversion

b)

Explicit Type Conversion

c)

None of the above

d)

Both A and B

5.

#include <stdio.h>


int main()


{


int a=40,b=20;


if (a>b) {


printf("a is greater than b");}


else if(a<b) {


printf("a is less than b"); }


else {


printf("a is equal to b");}


}

What is the output of the code?

a)

a is greater than b

b)

a is equal to b

c)

a is less than b

d)

compilation error

6.

int main()

{

switch(24.5)

{

case 24.5: printf("A ");break;

case 25.0: printf("B "); break;

default: printf("None ");

}

printf("Done");

}

What is the output of the above C Program?

a)

Compiler error

b)

Done

c)

A , Done

d)

B , Done

7.

#include <stdio.h>

int main()

{

int x = 5;

if (x < 1)

printf("x<1");

if (x == 5)

printf("x=5");

else

printf("none");

}

what is the output of the following code?

a)

x=5

b)

x<1

c)

none

d)

error

8.

Why can typecasting be dangerous in some cases?

a)

Some conversions are not defined, such as char to int.

b)

You might temporarily lose part of the data - such as truncating a float when typecasting to an int.

c)

You might permanently change the value of the variable.

d)

There are no dangers in typecasting.

9.

#include<stdio.h>

int main()

{

int i = 2;

if(i == (1, 2))

printf("1 or 2");

else

printf("None");

return 0;

}

what will be the output of above programme?

a)

Compilation error

b)

1 or 2

c)

None

d)

Run time error

10.

Which is a good use for typecasting?

a)

To allow your program to use nothing but integers.

b)

To change the return type of a function.

c)

To allow the division of two integers to return a decimal value.

d)

To swap variables rapidly.