wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C programming Midterm

Total questions: 94

Worksheet time: 54mins

Name
Class
Date
1.

Which library is used for input output in C++?

a)

<stdio.h>

b)

<stdlib.h>

c)

<iostream.h>

d)

<math.h>

2.

Switch Statement

a)

Is a statement with a set of conditions called cases

b)

Is a case

c)

Is a condition with no cases

d)

Is a boolean statement

3.

cstdlib

a)

Can convert a number into a letter

b)

It doesn't have any use

c)

Is the same as iostream

d)

Can convert a number into absolute number

4.

ctime

a)

Manipulates your CPU

b)

Manipulates other libraries

c)

Manipulates date and time information

d)

It just counts

5.

For a random number generator, you write it as

a)

sin()

b)

rand()

c)

cos()

d)

abs()

6.
The process of creating a new variable without value
a)
declaration
b)
naming
c)
instantiation
d)
assigning
7.
Which command moves the shown text to the next line?
a)
\t
b)
\n
c)
\r
d)
\s
8.
What is the output of this program?
Program
int main()
{
cout<<"Hi everybody";
return 0;
}
a)
"Hi everybody"
b)
Hi everybody"
c)
Hi everybody
d)
"Hi everybody
9.

Which of the following is NOT a logical operator in C++ language?

a)

&

b)

&&

c)

||

d)

!

10.

If originally x=2,y=0, and z=1, what is the value of x, y, and z after executing the following code?


if (x>y)


y=x;

else

z=x;

a)

x=2 y=2 z=1

b)

x=0 y=2 z=0

c)

x=2 y=1 z=1

d)

x=2 y=0 z=1

11.
a)

0

b)

5

c)

-5

d)

10

e)

-10

12.

A function can have _____ inside the parenthesis

a)

loops

b)

Arguments/Parameters

c)

Braces

d)

Types

13.

A function that has no return type starts with:

a)

int

b)

void

c)

Arguments

d)

Braces

14.

A function that is not void needs to have a _____ _______

a)

variable calculation

b)

printing statement

c)

Return statement

d)

cout statement

15.

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

a)

{ }

b)

-> and <-

c)

BEGIN and END

d)

( and )

16.

Which of the following is a correct comment?

a)

*/ Comments */

b)

** Comment **

c)

/* Comment */

d)

{ Comment }

17.
... variables store whole numbers (-4, 3, 51, etc). 
a)
Float
b)
Logical
c)
Character
d)
Integer
18.

What does <= mean?

a)

less than

b)

greater than

c)

less than or equal to

d)

greater than or equal to

19.
a)

Equal strings

b)

There will be a compile error and it will not run

c)

Nothing will be output on the console

d)

None of the above

20.

Do while loops

a)

Runs a statement once

b)

Runs a statement twice

c)

Runs a statement multiple times or not within a boolean condition

d)

Doesn't run at all

21.

int main()


{


int a = 10, b = 25;


a = b++ + a++;


b = ++b + ++a;


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


}

a)

36 64

b)

35 62

c)

36 63

d)

30 28

22.

int main ()


{


int x = 24, y = 39, z = 45;


z = x + y;


y = z - y;


x = z - y;


printf ("n%d %d %d", x, y, z);


}

a)

24 39 63

b)

39 24 63

c)

24 39 45

d)

39 24 45

23.

Who is Father of C Language

a)

Bjarne Stroustrup

b)

James A. Gosling

c)

Dennis Ritchie

d)

Dr. E.F. Codd

24.

C Language is 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

25.

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.

26.

Which is the only function all C programs must contain?

a)

start()

b)

system()

c)

printf()

d)

main()

27.

Which of the following is not a correct variable type?

a)

float

b)

real

c)

int

d)

char

28.

int main ()

{

int x = 24, y = 39, z = 45;

z = x + y;

y = z - y;

x = z - y;

printf ("%d %d %d", x, y, z);

}

a)

24 39 63

b)

39 24 63

c)

24 39 45

d)

39 24 45

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

The process of removing a bug is known as

a)

Debugging

b)

Compilation

c)

Executing

d)

Running

31.

Every C Program Statement must be terminated with a

a)

.

b)

#

c)

;

d)

!

32.

Which of the following is the boolean operator for logical-AND?

a)

&

b)

&&

c)

|

d)

||

33.

All keywords in C are in ____________

a)

Lowercase

b)

Uppercase

c)

Camelcase

d)

None of these

34.

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

a)

int a3;

b)

int 3a;

c)

int _A3;

d)

int a_3

35.

The functions printf() and scanf() are defined in which of the following library file:-

a)

math.h

b)

conio.h

c)

stdio.h

d)

stdlib.h

36.

Which is variable declaration?

a)

int a,b;

b)

c=a+b;

c)

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

d)

scanf("%d%d",&a,&b);

37.
How will you print \n on the screen?
a)
printf("\n");
b)
echo "\\n";
c)
printf('\n');
d)
printf("\\n");
38.
Which of the following is the correct operator to compare two variables?
a)
:=
b)
=
c)
equal
d)
==
39.
Which symbol terminates a C statement?
a)
.
b)
;
c)
,
d)
}
40.
How to comment in C language?
a)
//Comment
b)
A & B
c)
* Comment *
d)
<---Comment---->
41.

Process of writing the C source code is called as ___________________

a)

Editing

b)

LInking

c)

Executing

42.

C programming consists of two section which are _________________ and ___________________

a)

Pre-processor directives ; Main function

b)

Pre-processor directives ; end statement

c)

statements ; Main function

43.
Which one will return an value?
a)
give 1;
b)
rerun 2;
c)
*a = 1;
d)
return 1;
44.
To add a certain amount (often 1), once or many times
a)
Increment
b)
Decrement
c)
Decompose
d)
Automate
45.
Instructions that can be understood and followed by a machine
a)
Data
b)
Program
c)
Automate
d)
Programming
46.

While assigning a value to a variable, which operators are used to perform arithmetic operations?

a)

Logical operator

b)

Assignment operator

c)

Increment operator

d)

Conditional opertor

47.

An Integrated Development Environment typically consists of:

a)

A text editor

b)

A compiler

c)

A debugger

d)

All of these

48.

Computer programs are also known as:

a)

Hardware

b)

Firmware

c)

Software

d)

Silverware

49.

What is the extension of C program source code?

a)

.cpp

b)

.py

c)

.c

d)

.java

50.

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

51.

Which line of code is correct for the statement:

Add 1 variable to x.

a)

x++;

b)

x+1

c)

x+x

52.

Choose a correct C Statement.

a)

a++ is (a=a+1) POST INCREMENT Operator

b)

a-- is (a=a-1) POST DECREMENT Operator

--a is (a=a-1) PRE DECREMENT Operator

c)

++a is (a=a+1) PRE INCREMENT Operator

d)

All the above.

53.

The value 132.54 can be represented using which data type?

a)

double

b)

void

c)

int

d)

bool

54.

Which of the following is the boolean operator for logical-OR?

a)

&

b)

&&

c)

|

d)

||

55.

Which of the following is the boolean operator for logical-NOT?

a)

&

b)

&&

c)

!

d)

||

56.

What does <= mean?

a)

less than

b)

greater than

c)

less than or equal to

d)

greater than or equal to

57.

what data type store whole numbers?

a)

Float

b)

Character

c)

Logical

d)

Integer

58.

Which of the function is more appropriate for reading a multi-word string?

a)

puts()

b)

printf()

c)

scanf()

d)

gets()

59.

How does strings are declared?

a)

1. String name;

b)

Char name [20];

c)

Char name{20};

d)

None of the above

60.

The process of creating a new variable without value.

a)

declaration

b)

naming

c)

instantiation

d)

assigning

61.

%d format specifier does

a)

used to print an integer value.

b)

used to print a string.

c)

used to display a character value.

d)

used to display a floating point value.

62.

what is Global variable

a)

A variable which is declared inside function

b)

A variable which is declared outside function

c)

The scope of a variable is available within a function in which they are declared.

d)

Variables can be accessed only by those statements inside a function in which they are declared.

63.

Who is the father of C language?

a)

Steve Jobs

b)

James Gosling

c)

Dennis Ritchie

d)

Rasmus Lerdorf

64.

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

a)

int number;

b)

float rate;

c)

int variable_count;

d)

int $main;

65.

Which of the following is true for variable names in C?

a)

They can contain alphanumeric characters as well as special characters

b)

It is not an error to declare a variable to be one of the keywords(like goto, static)

c)

Variable names cannot start with a digit

d)

Variable can be of any length

66.

Which is valid C expression?

a)

int my_num = 100,000;

b)

int my_num = 100000;

c)

int my num = 1000;

d)

int $my_num = 10000;

67.

Which of the following cannot be a variable name in C?

a)

volatile

b)

true

c)

friend

d)

export

68.

Which of the following declaration is not supported by C language?

a)

String str;

b)

char *str;

c)

float str = 3e2;

d)

Both String str; & float str = 3e2;

69.

What is the result of logical or relational expression in C?

a)

True or False

b)

0 or 1

c)

0 if an expression is false and any positive number if an expression is true

d)

None of the mentioned

70.

Functions in C Language are always

a)

Internal

b)

External

c)

Both Internal and External

d)

External and Internal are not valid terms for functions

71.
Whitespace character does not giveany visible mark, but occupies an area on the page. Which of the following does not result in to white space?
a)
\\' backslash
b)
'\n' newline
c)
'\v' vertical tab
d)
'\r' carriage return
72.
Keywords are predefined reserved words in c. Which of the following ia a set of keywords in c?
a)
no, for, do
b)
true, while, constant
c)
do, for, if
d)
type, float, int
73.
Which keyword is used to prevent any changes in the variable within a C program?
a)
static
b)
const
c)
constant
d)
fixed
74.

A programmer has declared the variables as

int A = 9;

float a = 9.6;

Which of the following statement is correct

a)
Value in A will be 9.6
b)
Output depends on compiler
c)
Invalid declaration. Error
d)
Valid declaration. No error
75.

What is the result of the following

const int i = 3.67;

i = i + 3;

a)
3.67
b)
6.67
c)
6
d)
Error
76.

What value is stored in x, if its is declaed as

int i = 3.67;

a)
3.67
b)
"3.67"
c)
3
d)
4
77.
What is short int in C programming?
a)
The basic data type of C
b)
Qualifier
c)
Short is the qualifier and int is the basic data type
d)
All the above
78.
Programs written in few languages are executable on any machine. Such laguages are called as ___________
a)
Simple Language
b)
Structured Program
c)
Recursive Program
d)
Portable Language
79.
Group of instructions written to perform a task is called as_______.
a)
information
b)
comment
c)
array
d)
program
80.
c language has few backslash constants used for special purpose. They are also known as _________
a)
Free squence
b)
Escape sequence
c)
Exit Sequence
d)
Entry Sequence
81.
\n is a backslash constant for ________
a)
Vertical Tab space
b)
Horizontal Tab Space
c)
Form Feed
d)
New Line
82.
\t' is a backslash constant for ________
a)
Vertical Tab space
b)
Horizontal Tab Space
c)
Form Feed
d)
New Line
83.
\v is an escape sequence for _________
a)
Vertical Tab space
b)
Horizontal Tab Space
c)
Form Feed
d)
New Line
84.
\0 represents _________________
a)
Zero
b)
Null Character
c)
Division by Zero
d)
void data type
85.

As per C language standard, which of the following are not keywords? Pick the best statement.

int, when, make, elseif, sizeof

a)
when, make, elseif
b)
int, sizeof
c)
when, sizeof
d)
make, int, sizeof
86.
Each keyword is meant to perform a specific function in a C program. Keywords are also called as __________.
a)
Compiled words
b)
Reserved Words
c)
Constant Words
d)
Dumb Words
87.
Keywords are pre-defined words in a C compiler. How many keywords are in C.
a)
30
b)
31
c)
32
d)
33
88.
Keywords are pre-defined words in a C compiler. Keywords are written in ____________ case letters
a)
upper
b)
lower
c)
either lower or upper
d)
combined lower and upper
89.
Which o fthe following is a illegal variable name?
a)
update
b)
update_1
c)
Update
d)
1_update
90.
What is an array of characters, that end with a null character called?
a)
constant
b)
String
c)
Keyword
d)
Varaiable
91.
Which special symbol is used in arrays for specifying the subscript?
a)
{ }
b)
[ ]
c)
( )
d)
< >
92.

What is the problem in following variable declaration?

float 3Bedroom-Hall-Kitchen?;

a)
The variable name begins with an integer
b)
The special character ‘-‘
c)
The special character ‘?’
d)
All the above
93.
Which of the following is not a valid variable name declaration?
a)
float PI = 3.14;
b)
double PI = 3.14;
c)
int PI = 3.14;
d)
#define PI 3.14
94.
Which is valid C expression?
a)
int my_num = 100,000;
b)
int my_num = 10000;
c)
 int my num = 1000;
d)
int my(num) = 10000;