Font size
WorksheetsC programming Midterm
Total questions: 94
Worksheet time: 54mins
Which library is used for input output in C++?
<stdio.h>
<stdlib.h>
<iostream.h>
<math.h>
Switch Statement
Is a statement with a set of conditions called cases
Is a case
Is a condition with no cases
Is a boolean statement
cstdlib
Can convert a number into a letter
It doesn't have any use
Is the same as iostream
Can convert a number into absolute number
ctime
Manipulates your CPU
Manipulates other libraries
Manipulates date and time information
It just counts
For a random number generator, you write it as
sin()
rand()
cos()
abs()
Program
int main()
{
cout<<"Hi everybody";
return 0;
}
Which of the following is NOT a logical operator in C++ language?
&
&&
||
!
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;
x=2 y=2 z=1
x=0 y=2 z=0
x=2 y=1 z=1
x=2 y=0 z=1
0
5
-5
10
-10
A function can have _____ inside the parenthesis
loops
Arguments/Parameters
Braces
Types
A function that has no return type starts with:
int
void
Arguments
Braces
A function that is not void needs to have a _____ _______
variable calculation
printing statement
Return statement
cout statement
What punctuation is used to signal the beginning and end of code blocks?
{ }
-> and <-
BEGIN and END
( and )
Which of the following is a correct comment?
*/ Comments */
** Comment **
/* Comment */
{ Comment }
What does <= mean?
less than
greater than
less than or equal to
greater than or equal to
Equal strings
There will be a compile error and it will not run
Nothing will be output on the console
None of the above
Do while loops
Runs a statement once
Runs a statement twice
Runs a statement multiple times or not within a boolean condition
Doesn't run at all
int main()
{
int a = 10, b = 25;
a = b++ + a++;
b = ++b + ++a;
printf("%d %d n", a, b);
}
36 64
35 62
36 63
30 28
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);
}
24 39 63
39 24 63
24 39 45
39 24 45
Who is Father of C Language
Bjarne Stroustrup
James A. Gosling
Dennis Ritchie
Dr. E.F. Codd
C Language is developed at ___________?
AT & T's Bell Laboratories of USA in 1972
AT & T's Bell Laboratories of USA in 1970
Sun Microsystems in 1973
Cambridge University in 1972
C programs are converted into machine language with the help of
An Editor
A compiler
An operating system
None of these.
Which is the only function all C programs must contain?
start()
system()
printf()
main()
Which of the following is not a correct variable type?
float
real
int
char
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);
}
24 39 63
39 24 63
24 39 45
39 24 45
The process of removing a bug is known as
Debugging
Compilation
Executing
Running
Every C Program Statement must be terminated with a
.
#
;
!
Which of the following is the boolean operator for logical-AND?
&
&&
|
||
All keywords in C are in ____________
Lowercase
Uppercase
Camelcase
None of these
Which of the following is not a valid variable name declaration?
int a3;
int 3a;
int _A3;
int a_3
The functions printf() and scanf() are defined in which of the following library file:-
math.h
conio.h
stdio.h
stdlib.h
Which is variable declaration?
int a,b;
c=a+b;
printf("%d%d",a,b)
scanf("%d%d",&a,&b);
Process of writing the C source code is called as ___________________
Editing
LInking
Executing
C programming consists of two section which are _________________ and ___________________
Pre-processor directives ; Main function
Pre-processor directives ; end statement
statements ; Main function
While assigning a value to a variable, which operators are used to perform arithmetic operations?
Logical operator
Assignment operator
Increment operator
Conditional opertor
An Integrated Development Environment typically consists of:
A text editor
A compiler
A debugger
All of these
Computer programs are also known as:
Hardware
Firmware
Software
Silverware
What is the extension of C program source code?
.cpp
.py
.c
.java
What is machine language?
A language used by car
Machine language is made of 1's and 0's
Machine language is made of 7's and 8's
A language that only understands plain English
Which line of code is correct for the statement:
Add 1 variable to x.
x++;
x+1
x+x
Choose a correct C Statement.
a++ is (a=a+1) POST INCREMENT Operator
a-- is (a=a-1) POST DECREMENT Operator
--a is (a=a-1) PRE DECREMENT Operator
++a is (a=a+1) PRE INCREMENT Operator
All the above.
The value 132.54 can be represented using which data type?
double
void
int
bool
Which of the following is the boolean operator for logical-OR?
&
&&
|
||
Which of the following is the boolean operator for logical-NOT?
&
&&
!
||
What does <= mean?
less than
greater than
less than or equal to
greater than or equal to
what data type store whole numbers?
Float
Character
Logical
Integer
Which of the function is more appropriate for reading a multi-word string?
puts()
printf()
scanf()
gets()
How does strings are declared?
1. String name;
Char name [20];
Char name{20};
None of the above
The process of creating a new variable without value.
declaration
naming
instantiation
assigning
%d format specifier does
used to print an integer value.
used to print a string.
used to display a character value.
used to display a floating point value.
what is Global variable
A variable which is declared inside function
A variable which is declared outside function
The scope of a variable is available within a function in which they are declared.
Variables can be accessed only by those statements inside a function in which they are declared.
Who is the father of C language?
Steve Jobs
James Gosling
Dennis Ritchie
Rasmus Lerdorf
Which of the following is not a valid C variable name?
int number;
float rate;
int variable_count;
int $main;
Which of the following is true for variable names in C?
They can contain alphanumeric characters as well as special characters
It is not an error to declare a variable to be one of the keywords(like goto, static)
Variable names cannot start with a digit
Variable can be of any length
Which is valid C expression?
int my_num = 100,000;
int my_num = 100000;
int my num = 1000;
int $my_num = 10000;
Which of the following cannot be a variable name in C?
volatile
true
friend
export
Which of the following declaration is not supported by C language?
String str;
char *str;
float str = 3e2;
Both String str; & float str = 3e2;
What is the result of logical or relational expression in C?
True or False
0 or 1
0 if an expression is false and any positive number if an expression is true
None of the mentioned
Functions in C Language are always
Internal
External
Both Internal and External
External and Internal are not valid terms for functions
A programmer has declared the variables as
int A = 9;
float a = 9.6;
Which of the following statement is correct
What is the result of the following
const int i = 3.67;
i = i + 3;
What value is stored in x, if its is declaed as
int i = 3.67;
As per C language standard, which of the following are not keywords? Pick the best statement.
int, when, make, elseif, sizeof
What is the problem in following variable declaration?
float 3Bedroom-Hall-Kitchen?;
