wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C programming Basics

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

Which of the following are valid variable names in C?

a)

first_name

b)

123name

c)

_count

d)

#value

2.

Which of these are basic data types in C?

a)

int

b)

float

c)

char

d)

string

3.

Which are arithmetic operators in C?

a)

%

b)

/

c)

*

d)

+

e)

-

4.

Which header file is required for using printf function?

a)

#include<math.h>

b)

#include<conio.h>

c)

#include<stdio.h>

d)

#include<string.h>

5.

Which symbols are used for single line comments in C?

a)

//

b)

/* message */

c)

--

d)

#

6.

What is the purpose of scanf() function?

a)

Clear screen

b)

Exit program

c)

Read input

d)

Print output

7.

Which is the correct way to declare and initialize an integer variable?

a)

age=20

b)

var age=20

c)

integer age=20

d)

int age=20

8.

What are essential parts of a C program?

a)

Header files

b)

Main function

c)

Variables

d)

Classes

9.

Where is semicolon (;) required in C programs?

a)

Preprocessor directives

b)

End of statement

c)

Header inclusion

d)

Function declaration

10.

Which format specifier is used for integers in printf?

a)

%s

b)

%d

c)

%f

d)

%c

11.

How many bytes does a char data type occupy?

a)

2 bytes

b)

8 bytes

c)

4 bytes

d)

1 byte

12.

Which rules apply to C identifiers?

a)

Can start with number

b)

Can start with letter

c)

Can contain spaces

d)

Can use keywords

13.

Which symbols are used for code blocks in C?

a)

begin-end

b)

[ ]

c)

{ }

d)

( )

14.
a)

5 5

b)

5 10

c)

10 10

d)

10 5

15.
a)

24

b)

14

c)

20

d)

error

16.

printf("%d", -5 % 2);

a)

-1

b)

1

c)

-2

d)

Compiler dependent

17.

Which function is used to print output in C programming?

a)

cout

b)

printf()

c)

write()

d)

scanf()

18.

in which extension we need to save the program to run on c compiler.

a)

filename.cpp

b)

filename.c

c)

filename.jpeg

d)

filename.o

19.

Which is a valid variable name in C?

a)

#variable

b)

123variable

c)

my variable

d)

my_variable

20.

What is the scope of a local variable?

a)

Within function

b)

Within file

c)

Entire program

d)

Within block