wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C-programming(Theory)

Total questions: 146

Worksheet time: 7hrs 18mins

Name
Class
Date
1.

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

2.

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

3.

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("true\n");

else

printf("false\n");

}

a)

Depends on the compiler

b)

No print statement

c)

True

d)

False

4.

The switch statement takes a given integer value then seeks a matching value among a number of _______ statements.

a)

break

b)

case

c)

switch

d)

goto

5.

How many loops are there in C

a)

1

b)

3

c)

2

d)

4

6.

Which of the following is an exit control statement

a)

for

b)

while

c)

do while

d)

continue

7.

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

8.

The output of the following segment is

int k, n=20;

k=(n>5?(n<=10?100:200):500);

printf("%d",n);

a)

100

b)

200

c)

300

d)

20

9.

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

10.

which is the only function all C programs must contain?

a)

start()

b)

sys()

c)

main()

d)

scanf()

11.

Which of the following is not a correct variable type?

a)

float

b)

real

c)

int

d)

double

12.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int a = 1, b = 1, c;

c = a++ + b;

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

}

a)

a=1, b=1

b)

a=2, b=1

c)

a=1, b=2

d)

a=2, b=2

13.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int i = 0;

int j = i++ + i;

printf("%d\n", j);

}

a)

0

b)

1

c)

2

d)

compile time error

14.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int a = 1, b = 1;

switch (a)

{

case a*b:

printf("yes ");

case a-b:

printf("no\n");

break;

}

}

a)

yes

b)

no

c)

yes no

d)

compile time error

15.

Library function pow() belongs to which header file?

a)

math.h

b)

square.h

c)

stdio.h

d)

conio.h

16.

Is it possible to run program without main() function?

a)

yes

b)

no

c)

may be

17.

How many main() function we can have in our project?

a)

1

b)

2

c)

no limit

d)

depends on the program

18.

int x = 10;


int main()

{

int x = 0;

printf("%d",x);

return 0;

}

a)

10

b)

0

c)

compile error

d)

undefined

19.

What should be the output:

int main()

{

int a = 10/3;

printf("%d",a);

return 0;

}

a)

3.33

b)

3.0

c)

3

d)

0

20.

#include "stdio.h"

int main()

{

int a = 10;

printf("%d", a);

int a = 20;

printf("%d",a);

return 0;

}

a)

1020

b)

1010

c)

2020

d)

Error: Redeclaration of a

21.

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

a)

/ + * -

b)

* - / +

c)

+ - / *

d)

/ * + -

22.

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)

23.

Which of the following is not logical operator?

a)

&

b)

&&

c)

||

d)

!

24.

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

25.

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

a)

conio.h

b)

stdlib.h

c)

stdio.h

d)

dos.h

26.

which of the following is not a Looping statements?

a)

For

b)

While

c)

Do while

d)

Switch case

27.

Which command is used to skip the rest of a loop and carry on from the top of the loop again?

a)

break

b)

continue

c)

goto

d)

resume

28.

What will be the output of following program?

a)

true

b)

false

c)

6

d)

5

29.

what will be output of following program?

a)

6 7 7 8

b)

6 6 7 8

c)

6 6 8 8

d)

6 7 8 8

30.

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

31.

What is the output of C Program.?

int main()

{

int a=5;

while(a >= 3);

{

printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT GREEN

c)

RABBIT is printed infinite times

d)

None of the above

32.

Choose a right C Statement.

a)

Loops or Repetition block executes a group of statements repeatedly.

b)

Loop is usually executed as long as a condition is met.

c)

Loops usually take advantage of Loop Counter

d)

All the above.

33.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

if(a > 35)

break;

}

while(1);

return 0;

}

a)

No Output

b)

32 33 34

c)

32 33 34 35

d)

Compiler error

34.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

}

while(a <= 30);

return 0;

}

a)

32

b)

33

c)

30

d)

No Output

35.

Lines beginning with a hash sigh (#) are

a)

namespace

b)

directives

c)

object

36.

What does <= mean?

a)

less than

b)

less than or equal to

c)

greater than

37.

It is the point by where all C++ programs start their execution, independently of its location within the source code

a)

main()

b)

start()

c)

system()

38.

It represents the standard output stream of C++

a)

cout

b)

cin

c)

clrscr()

39.

The collective name given to spaces (blanks), horizontal and vertical tabs, newline characters, and comments

a)

comment

b)

new line

c)

whitepsace

40.

Tokens representing fixed numeric or character values.

a)

identifier

b)

constant

c)

directives

41.

Words reserved for special purposes and must not be used as normal identifier names

a)

variable

b)

namespace

c)

keywords

42.

Arbitrary names of any length given to classes, objects, functions, variables, user-defined data types, and so on

a)

keywords

b)

whitespace

c)

identifier

43.

A character used to mark the end of the statement

a)

braces

b)

semicolon

c)

colon

44.

C++ was originally developed by

a)

Bjarne Stroustrup

b)

Nicolas Wirth

c)

Ken Thompson

45.

Form a special category of constant used to handle fixed sequences of characters.

a)

Character Constant

b)

Escape Sequences

c)

String Constant

46.

It is a portion of memory to store a determined value

a)

variable

b)

constant

c)

directive

47.

Indicate the start and end of a compound statement

a)

braces

b)

comma

c)

semicolon

48.

Refer to the names of variables, functions, arrays, classes etc. created by the programmer.

a)

keywords

b)

constraints

c)

identifiers

49.

An identifiable region of memory that can hold a fixed or variable value

a)

directive

b)

identifier

c)

objects

50.

A sequence of operators, operands, and punctuators that specifies a computation.

a)

expression

b)

syntax

c)

statement

51.

It specify the flow of control as a program executes

a)

statement

b)

syntax

c)

expression

52.

It express numbers with decimals and/or exponents

a)

integer numerals

b)

floating point

c)

character literals

53.

A keyword used to execute a statement or block only if a condition is fulfilled

a)

objects keyword

b)

case keyword

c)

if keyword

54.

Which of the following is a correct C programming statement?

a)

printf(“Programming”)

b)

int num2=3

c)

scanf(“&num”, %d);

d)

printf(“ “);

55.

Which of the following is a correct syntax of printf?

a)

printf( strings );

b)

Printf(“Strings”);

c)

printf(“ strings “);

d)

None of these

56.

C programming is a case-sensitive?

a)

True

b)

False

57.

The format specifier/placeholder (a)   is used to print integers.

58.

The format specifier/placeholder (a)   is used to print floating points.

59.

The format specifier/placeholder (a)   is to used to print single character.

60.

The format specifier/placeholder (a)   is used to print string.

61.

The symbol (a)   is used to terminate the C statement .

62.

The symbol (a)   is used to address a variable.

63.

The escape sequence (a)   is used to create a new line.

64.

The escape sequence (a)   is used to create a horizontal tab.

65.

Which of the following variable declaration is correct?

a)

char char;

b)

int void;

c)

float _a;

d)

Float a=0;

66.

Given the code above, what is the expected output?

a)

Null

b)

Compilation Error

c)

“ “

d)

0

67.

Given the code above, what is the expected output?

a)

Syntax Error

b)

Null

c)

The value of a = -10

d)

Compilation Error

68.

Given the code above, Assumed that 5 was entered , what is the expected output?

a)

Enter a value of a: 5

You entered the value of a: 5

b)

Compilation error

c)

nothing

d)

Run time error

69.

Given the code above, assumed that HELLO was entered, what is the expected output?

a)

HELLO

b)

Compilation Error

c)

H

d)

Syntax Error

70.

The arithmetic (a)   operator is to get the remainder of an integer.

71.

The arithmetic (a)   operator is used to add the variable value or to the operand.

72.

The arithmetic (a)   operator is used to subtract the value of the variable or to the operand.

73.

What is stdio stands for? (a)  

74.

At the heart of computer is its central processing unit. The CPU's job is:

a)

To fetch instructions

b)

To carry out the operations commanded by the instructions

c)

To produce some outcome or resultant information

d)

All of these

75.

An Integrated Development Environment typically consists of:

a)

A text editor

b)

A compiler

c)

A debugger

d)

All of these

76.

___ is used to translate source code instructions into the appropriate machine language instructions

a)

Module

b)

Library routine

c)

Compiler

d)

Preprocessor directives

77.

A ____ is a set of instructions that the computer follows to solve a problem.

a)

Comipler

b)

Linker

c)

Program

d)

Operator

78.

The program written by the programmer with high level language is called:

a)

Object Code

b)

Syntax

c)

Source Code

d)

Runtime Library

79.

Computer programs are also known as:

a)

Hardware

b)

Firmware

c)

Software

d)

Silverware

80.

The primary purpose of an operating system is:

a)

To make the most efficient use of the computer hardware

b)

To make programming easier

c)

To fetch instructions

d)

To prevent multitask

81.

What is the extension of C program source code?

a)

.cpp

b)

.py

c)

.c

d)

.java

82.

What is machine language?

a)

A language used by car

b)

Machine language is made of 1's and 0's

c)

Machine language is made of 7's and 8's

d)

A language that only understands plain English

83.

Which of the following is not a high level programming language?

a)

Assembly

b)

C++

c)

Java

d)

Python

84.

Algorithm refers to a pictorial representation of a flowchart

a)

True

b)

False

85.

Who is Father of C Language

a)

Bjarne Stroustrup

b)

James A. Gosling

c)

Dennis Ritchie

d)

Dr. E.F. Codd

86.

C programs are converted into machine language with the help of

a)

An Editor

b)

A compiler

c)

An operating system

d)

None of these.

87.

Which is the only function all C programs must contain?

a)

start()

b)

system()

c)

printf()

d)

main()

88.

Which of the following is not a correct variable type?

a)

float

b)

real

c)

int

d)

char

89.
What punctuation is used to indicate the beginning and end of code blocks?
a)
{ }
b)
-> <-
c)
BEGIN and END
d)
( and )
90.

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

a)

conio.h

b)

stdlib.h

c)

stdio.h

d)

dos.h

91.

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

a)

equal

b)

=

c)

:=

d)

==

92.

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

93.

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

a)

%

b)

/

c)

\

d)

*

94.
What is machine code?
a)
Instructions converted by a translator
b)
Instructions in an HLL used by the CPU
c)
Instructions in binary used by the CPU
d)
Instructions in assembly used by the CPU
95.
What is a translator?
a)
A program that converts commands into machine code
b)
A program that converts HLL to assembly code
c)
A program that converts the inputs from a keyboard
d)
A program for writing code
96.
What is Assembly code?
a)
Another name for Pseudocode
b)
A programming language that uses mnemonic codes
c)
A program that joins pieces of code together
d)
Another name for machine code
97.
What does IDE stand for?
a)
Integrated Debugging Equipment
b)
Integrated Debugging Environment
c)
Integrated Development Equipment
d)
Integrated Development Environment
98.
Which of these would you NOT find in an IDE?
a)
Debugger
b)
Picture Editor
c)
Auto Documentation
d)
Source Code Editor
99.
Which of these is an example of an IDE?
a)
Eclipse
b)
Twilight
c)
Moon
d)
Planet
100.
Which of these is NOT an example of a High Level Language?
a)
Python
b)
Java
c)
C++
d)
Avalon
101.
What is an interpreter?
a)
Converts source code one instruction at a time
b)
Converts source code between 2 HLLs
c)
Converts source code between HLL and Assembly
d)
Converts keyboard presses to an ASCII code
102.
What would you use to convert high-level source code to machine code?
a)
Linker
b)
Assembler
c)
Compiler
d)
IDE
103.
Which of these is NOT a disadvantage of an interpreter?
a)
Executes slowly
b)
Occupies more space
c)
Source code can be modified
d)
Initial compilation is slow
104.

What is the value of this expression using integer arithmetic:

7 / 4

a)

1

b)

2

c)

1.75

105.

What is the value of a in this code fragment

int a=3, b;

a)

0

b)

Nothing

c)

3

106.

Determine the value of this expression using integer arithmetic:

5 % 7

a)

0

b)

2

c)

5

107.

Determine the value of b in this code fragment:

int a=3, b;

b=++a;

a)

3

b)

4

c)

2

108.

Determine the value of the expression using integer arithmetic:

6 * 9 % 3 / 2

a)

2

b)

0

c)

18

109.

Determine the value of a in the second line of the code fragment:

int a=1, b=2;

a=b--;

a)

1

b)

0

c)

2

110.

Determine the value of b in the second line of the code fragment:

int a=1, b=2;

a=b--;

a)

1

b)

0

c)

2

111.

Which line of code is correct for the statement:

Add 1 variable to x.

a)

x++;

b)

x+1

c)

x+x

112.

Which line of code is incorrect for the statement:

Subtract 4 from the variable y.

a)

y-4

b)

y=y-4

c)

y-=4

113.

Which line of code is correct for the statement:

Read in a value for the integer variable num.

a)

printf("%d", &num);

b)

scanf("%d", num);

c)

scanf("%d", &num);

114.

What is the EXACT output from this code fragment:

float num=3.238;

printf("num=%.2f", num);

a)

Number=3.2

b)

num=3.238

c)

num=3.24

115.

What is the EXACT output from this code fragment:

int num=10;

if(num> 7 % 3 / 2 * 3)

printf("This is True");

else

printf("This is False");

a)

This is True

b)

This is False

116.

What symbol is used in conditional operators for AND:

a)

AND

b)

&&

c)

&

117.

What will be printed on the screen from this fragment:

int num=0;

printf("%d", ++num)

a)

0

b)

1

c)

2

118.

What is the abbreviated way to write this assignment statement:

total=total+num;

a)

t=t+n;

b)

total+=num

c)

total=(total+num)

119.
Example of First Generation Programming Language
a)
COBOL
b)
Machine Language
c)
C++
120.
Third Generation Programming Language also known as 
a)
Natural Language
b)
High Level Programming Language
c)
Very High Level Programming Language
121.
SQL , NOMAD and FOCUS are examples of .............. Generation Programming Language
a)
Third
b)
Fourth
c)
Fifth
122.
2 types of programming language approaches are Object Oriented Approach and .....................
a)
Structural Approach
b)
Sequence Approach
c)
Structured Approach
123.
What is X?
a)
Implementation Phase
b)
Coding Phase
c)
Writing Phase
d)
Development Phase
124.
"A set of specific procedures, which consists of, step by step instructions to solve the problem must be develop using pseudo code or flow chart"
The statement above refer to ........................ phase
a)
Problem Analysis
b)
Program Design
c)
Documentation
125.
"The program done will be tested to ensure that is error free."
The statement above refer to ................. phase
a)
Testing
b)
Coding
c)
Testing and Debugging
126.
"Produce a description of the program, layouts of the input and output record and a program listing such as user manual. "
The statement above refer to
a)
Problem Analysis
b)
Program Design
c)
Documentation
127.
A series of step by step instructions telling the computer what to do is called ............
a)
Programming
b)
Program
c)
Programming Language
128.

What is the output given by this C code?

a)

3210

b)

321

c)

Compiler error

d)

3

129.

In C programming language, what is the symbol II?

a)

Arithmetic operator

b)

This symbol is unrecognised in C

c)

Logical operator

d)

This is the name typically given to an int variable

130.

Fill the blank: instruction _____ is used to provide a value to the instruction that called a function

a)

result

b)

return

c)

exit

d)

break

131.

In C variables can ONLY be declared as numeric?

a)

TRUE

b)

FALSE

132.

Which instruction will print on the screen exactly the text \n?

a)

printf(“n\”);

b)

printf(“n”);

c)

printf(“\\n”);

d)

printf(“\n”);

133.
a)

a=5, b=3, 0

b)

a=5, b=3, c=4

c)

a=5, b=3

d)

Compiler error

134.

Which symbol always finalizes an instruction in C code?

(a)  

135.

Is this code correct? (no errors or warnings)

a)

No, the name myprint is not correct

b)

Yes, there is no problem at all

c)

No, if it indicates int in the signature, a value should be returned

d)

Yes, but k is printed as a double number

136.

What is a pointer in C?

a)

Any element in a C program

b)

It refers to the memory address of a variable

c)

It is exactly a regular variable

d)

It is a specific kind of function

137.

Which instruction is for choosing among multiple options depending on the value of a single variable? (Just one word in lowercase)

(a)  

138.

A single-line comment in C starts by...

a)

/*

b)

//

c)

;

d)

:

139.

Fill the gap: A _______ variable, declared in a function, will only be available for that function

a)

local

b)

global

c)

fake

d)

lazy

140.

Fill the gap: If a parameter received by a function could be changed, pass-by-__________ is necessary

a)

value

b)

reference

c)

free

141.

One _________ is a derived datatype, built using several elements which could be from distinct datatype

a)

loop

b)

array

c)

include

d)

struct

142.

The collection of multiple elements of the same nature and linearly indexed under the same name is called...

a)

struct

b)

array

c)

matrix

d)

variable

143.

Could we assign a float variable to a long integer in C?

a)

YES

b)

NO

144.

When inside a function a call to itself is done we call it...

a)

Iteration

b)

Reiteration

c)

Recursion

d)

This is forbidden

145.

One constant is…

a)

Procedure/function which always does the same

b)

Global variable all functions can use

c)

Global variable all procedures can use

d)

Value which can not be modified after its declaration

146.

What is the term for ..."a sequence of logical instructions or steps needed to finish a task. Can be performed with or without a computer"?

a)

design

b)

coding

c)

algorithm

d)

program