Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

UC_TM02_C Programming Basics

Total questions: 16

Worksheet time: 7mins

Name
Class
Date
1.

Which of the following statement is false?

a)

Name of the variable can have letters,digits and underscore

b)

Upper case and Lower case letters are distinct in C

c)

Variable name can begin with digit

d)

Variable name cannot have C reserved words

2.

To calculate the remainder which of the following option is used?

a)

a mod b

b)

a%b

c)

a/b

d)

a^b

3.

Which of the following is not a valid data type?

a)

char

b)

int

c)

short

d)

bigint

4.

What will be the output ?

int main()

{

int x=10,y=20,res;

res = (x < y) ? x : y;

printf("output %d " , res);

return 0;

}

a)

compile error

b)

10

c)

20

d)

run time error

5.

Char datatype will be allocate storage size of ?

a)

2 byte

b)

4 byte

c)

8 byte

d)

1 byte

6.

which of the following is not a valid identifier?

a)

1empno

b)

emp_1_no

c)

empno1

d)

emp_no1

7.

Which of the below is not a built in or primary datatype in C?

a)

int

b)

char

c)

float

d)

enum

8.

What will the output of the following code?


int main() {

const int X = 10;

X=20;

printf("value of x : %d",X);

return 0;

}

a)

10

b)

20

c)

compile error: assignment of read-only variable ‘X’

d)

run time error

9.

What will be displayed as the value of x?


int main() {

int x;

x=(10%2+5/2*3);

printf("value of x is : %d " , x);

return 0;

}

a)

6

b)

1

c)

7

d)

0

10.

What will be the output of the below code?


int main() {

int x=10;

int y;

y=x++;

printf("value of x is : %d %d " , x , y);

return 0;

}

a)

11 11

b)

11 10

c)

10 10

d)

10 11

11.

What will be output?


int main() {

int x=10;

printf("value of x is : %d " , sizeof(x));

return 0;

}

a)

2

b)

compile error

c)

4

d)

run time error

12.

What will the output?


int main() {

int x=1,n=5;

do{

printf(" %d ",x);

x=x+1;

}while(n>5);

return 0;

}

a)

1 2 3 4 5

b)

1 2 3 4

c)

1

d)

1 2

13.

Which statement terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch.

a)

end

b)

break

c)

goto

d)

none of the above

14.

The _________header file which contains the input output functions .

a)

input.h

b)

inpout.h

c)

stdio.h

d)

output.h

15.

An integer literal can have ________ constant.

a)

decimal

b)

octal

c)

hexadecimal

d)

all of the above

16.

What will be output of the following code?


int main() {

int x=10;

char ch='a';

printf("%d",x+ch);

return 0;

}

a)

107

b)

compile error

c)

run time error

d)

10a