wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

BASIC C QUIZ

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

____________ is a datatype format specifier used to print and scan an integer value.

a)

%f

b)

%d

c)

%c

d)

%s

2.

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

a)

a) int number;

b)

b) float rate;

c)

c) int variable_count;

d)

d) int $main;

3.

All keywords in C are in ____________

a)

a) LowerCase letters

b)

b) UpperCase letters

c)

c) CamelCase lettersned

d)

d) None of the mentioned

4.

Which is valid C expression?

a)

a) int my_num = 100,000;

b)

b) int my_num = 100000;

c)

c) int my num = 1000;

d)

d) int $my_num = 10000;

5.

What will be the final value of x in the following C code?

#include <stdio.h>

void main()

{

int x = 5 * 9 / 3 + 9;

}

a)

a) 3.75

b)

b) Depends on compiler

c)

c) 24

d)

d) 3

6.

Which of the following declaration is not supported by C?

a)

A.String str;

b)

B. char *str;

c)

C. float str = 3e2;

d)

D. int s[20];

7.

How many characters can a string hold when declared as follows?

char name[20]:  

a)

18

b)

19

c)

20

d)

None of the these

8.

 What is the output of this program?

#include <stdio.h>

int main()

{

printf("variable! %d", x);

return 0;

}

a)

A. variable! x

b)

B. variable! followed by a junk value

c)

C. Compile time error

d)

D. variable!

9.

Which of the following is an invalid method for input?

a)

a.scanf(“%d%d%d”,&a, &b, &c);

b)

b.scanf(“%d %d %d”, &a, &b, &c);

c)

c.scanf(“Three values are %d %d %d”,&a,&b,&c);

d)

d.none of the mentioned

10.

scanf returns as its value

a)

a.Number of successfully matched and assigned input items

b)

b.Nothing

c)

c.Number of characters properly printed

d)

d.Error

11.

What is the output of this C code?

#include <stdio.h>

void main()

{

int n;

scanf("%d", n);

printf("%d", n);

}

a)

a.Prints the number that was entered

b)

b.Segmentation fault

c)

c.Nothing

d)

d.Varies

12.

What is the output of this C code (when 4 and 5 are entered)?

a)

a.Error

b)

b.4 junkvalue

c)

c.Junkvalue 5

d)

d.4 5

13.

What is the output of the following code snippet?

int main()

{

int sum = 2 + 4 / 2 + 6 * 2;

printf("%d", sum);

return 0;

}

a)

2

b)

15

c)

5

d)

16

14.

What is the correct order of precedence of arithmetic operators from highest to lowest?

a)

%, , /, +, –

b)

-, +, , /, %

c)

%, +, -, , /

d)

+, – , %, , /

15.

Which of the following is not an arithmetic operation?

a)

a*=5;

b)

a/=5;

c)

a!=5;

d)

a%=5;