wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C-Programming Basics

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

Which of the following correctly shows the hierarchy of arithmetic operations in C?

a)

/ + * -

b)

* - / +

c)

+ - / *

d)

/ * + -

2.

To print out 'a' as an integer and 'b' as a decimal, which of the following printf() statement will you use?

a)

printf("%f %lf", a, b)

b)

printf("%f %f", a, b)

c)

printf("%d %f", a, b)

d)

printf("%f %d", a, b)

3.

Which of the following is not logical operator?

a)

&

b)

&&

c)

||

d)

!

4.

When does the code block following while(x<100) execute?

a)

When x is less than one hundred

b)

When x is greater than one hundred

c)

When x is equal to one hundred

d)

while it wishes

5.

Input/output function prototypes and macros are defined in which header file?

a)

conio.h

b)

stdlib.h

c)

stdio.h

d)

dos.h

6.

What is the output of this C code?

#include <stdio.h>

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!

7.

Which of the following is not a correct variable type?

a)

int

b)

real

c)

float

d)

char

8.

Which of the following is the correct operator to compare two variables?

a)

equal

b)

=

c)

:=

d)

==

9.

What is the correct value to return to the operating system upon the successful completion of a program?

a)

1

b)

0

c)

-1

d)

program do not return a value

10.

What is the only function all C programs must contain?

a)

start()

b)

system()

c)

main()

d)

Program()

11.

What punctuation is used to signal the beginning and end of code blocks?

a)

{ }

b)

-> and <-

c)

BEGIN and END

d)

( and )

12.

The "\n" character does which of the following operations?

a)

Double line spacing

b)

Character deletion

c)

Character backspace

d)

Places cursor on the next line

13.

Is the syntax for the following C statement correct?:


scanf("%d", input);

a)

True

b)

False

14.

Which arithmetic operator in C returns the integer remainder of the result of dividing its first operand by its second?

a)

%

b)

/

c)

\

d)

*

15.

The compiler ignores comments and they are not translated into machine language.

a)

True

b)

False

16.

You can have more than one main function.

a)

True

b)

False