wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Programming

Total questions: 31

Worksheet time: 17mins

Name
Class
Date
1.

What will happen when the following code is executed?

void main()

{

printf("MIET");

main();

}

a)

Wrong statement

b)

It will keep on printing MIET

c)

It will print MIET once

d)

None of these

2.

What is the result after execution of the following code if a is 10, b is 5, and c is 10?

if ((a > b) && (a <= c))

a = a + 1;

else

c = c+1;

a)

a = 10, c = 10

b)

a = 11, c = 10

c)

a = 10, c = 11

d)

a = 11, c = 11

3.

What will the result of 'num' variable after execution of the following statements?

int num = 58;

num % = 11;

a)

3

b)

5

c)

8

d)

11

4.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

int x = 5;

if (x < 1)

printf("hello");

if (x == 5)

printf("hi");

else

printf("no");

}

a)

hi

b)

hello

c)

no

d)

error

5.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int x = 0;

if (x == 1)

if (x == 0)

printf("inside if\n");

else

printf("inside else if\n");

else

printf("inside else\n");

}

a)

inside if

b)

inside else if

c)

inside else

d)

compile time error

6.

The value of i after the execution of the following segment is

i = 2;

for( i=0; i>10; i=i+1);

a)

1

b)

2

c)

0

d)

11

7.

C language developed at _____?

a)

AT & T's Bell Laboratories of USA in 1972

b)

AT & T's Bell Laboratories of USA in 1970

c)

Sun Microsystems in 1973

d)

Cambridge University in 1972

8.

which is the only function all C programs must contain?

a)

start()

b)

sys()

c)

main()

d)

scanf()

9.

Which of the following is not a correct variable type?

a)

float

b)

real

c)

int

d)

double

10.

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

a)

/ + * -

b)

* - / +

c)

+ - / *

d)

/ * + -

11.

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)

12.

Which of the following is not logical operator?

a)

&

b)

&&

c)

||

d)

!

13.

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

a)

equal

b)

=

c)

:=

d)

==

14.

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

15.

Is the syntax for the following C statement correct?:


scanf("%d", input);

a)

True

b)

False

16.

Find the output in following code

int main ()

{

int a,b ;

a= b= 4 ;

b =a++;

Printf ( " %d %d %d %d", a++, --b, ++a, b--);

}

a)

5 3 73

b)

5 4 5 3

c)

6 2 6 4

d)

Syntax Error

17.

Find Error/ output in following code

int main ()

{

int x = 1;

While (x= 0)

printf (" Hello");

}

a)

Hello

b)

No output

c)

Infinite time Hello display

d)

Error in code

18.

Find Error/ output in following code

Void main ()

{

printf ( " % d " , printf ( " computer science"));

}

a)

Computer science16

b)

16computer science

c)

Computer science

d)

Computer science18

19.

What will be the output of the program?

int main ()

{

printf ( 5+"Good Morning\n");

return 0;

}

a)

Good Morning

b)

Good

c)

M

d)

Morning

20.
The keyword used to transfer control from a function back to the calling function is
a)
switch
b)
goto
c)
go back
d)
return
21.

1. What will be the output of following program?

a)

1 2 3 4 5

b)

1 2 3 4

c)

6

d)

5

22.
What is used to connect the flowchart symbols together?
a)
Rectangles
b)
Lines
c)
Arrows
d)
Patterns
23.
What is the purpose of a flowchart?
a)
To plan the program before it is made
b)
Because it is easier
24.
What is the Output if the user enters:
Yes
a)
Leave umbrella at home
b)
Take an umbrella
25.

In basic flowchart symbol, a circle is called ______

a)

Start/Stop

b)

Comment

c)

Connector

26.

This is used for planning and solving a problem.

a)

Algorithm

b)

Flowchart

c)

Pseudocode

27.

Is it important for a programmer to plan the logic of his program?

a)

Yes

b)

No

28.
We can show the sequence of steps in an algorithm in a structural diagram called a flow chart.
a)
True
b)
False
29.
Only top software programmers can write an algorithm.
a)
True
b)
False
30.
What should be considered when designing an algorithm?
a)
If the correct hardware is being used
b)
If the correct software is being used
c)
If there is more than one way of solving the problem
31.
An Algorithm has 4 main characteristics. It should be....
a)
Doable, Creative, finite and precise
b)
Doable, Understandable, finite and precise
c)
Amazing, Understandable, finite and precise
d)
Doable, Understandable, Infinite and precise