WorksheetsBasics of programming (C/C++)
Total questions: 25
Worksheet time: 12mins
Which header file can be used to define input/output function prototypes and macros?
- math.h
- memory.h
- stdio.h
- dos.h
The correct order of evaluation for the expression “z = x + y * z / 4 % 2 – 1”
* / % = + -
/ * % - + =
- + = * % /
* / % + - =
What is output of below program?
int main()
{
int i,j,count;
count=0;
for(i=0; i<5; i++);
{
for(j=0;j<5;j++);
{
count++;
}
}
printf("%d",count);
return 0;
}
55
54
1
0
What is an Identifier in C Language.?
Name of a Function or Variable
Name of a Macros
Name of Structure or Union
All the above.
Number of Keywords present in C Language are .?
32
34
62
64
To print out 'a' as an integer and 'b' as a decimal, which of the following printf() statement will you use?
printf("%f %lf", a, b)
printf("%f %f", a, b)
printf("%d %f", a, b)
printf("%f %d", a, b)
Which of the following is not a correct variable type?
int
real
float
char
Which of the following is the correct operator to compare two variables?
equal
=
:=
==
What is the only function all C programs must contain?
start()
system()
main()
Program()
Is the syntax for the following C statement correct?:
scanf("%d", input);
True
False
Library function pow() belongs to which header file?
mathio.h
math.h
square.h
stdio.h
You want to show some code if the age is over 18, which is the correct command? (c#)
IF (age > 18)
IF (age >= 18)
IF age > 18
IF (age > "18")
Which is the odd one out?
IF
WHILE
FOR
DO...UNTILL
How many basic data types are there?
3
4
as many as you want
data types?
You need an variable to act as a counter, what would be the best data type to use?
Real/Float
Integer
String
Bool
Choose a right C Statement.
Loops or Repetition block executes a group of statements repeatedly.
Loop is usually executed as long as a condition is met.
Loops usually take advantage of Loop Counter
All the above.
What is the output of C Program.?
int main()
{
int a=25;
while(a <= 27)
{
printf("%d ", a);
a++;
}
return 0;
}
25 25 25
25 26 27
27 27 27
Compiler error
Choose correct Syntax for C Arithmetic Compound Assignment Operators.
a+=b is (a= a+ b)
a-=b is (a= a-b)
a*=b is (a=a*b)
a/=b is (a = a/b)
a%=b is (a=a%b)
All the above.
Choose a correct C for loop syntax.
for(initalization; condition; incrementoperation) { //statements }
for(declaration; condition; incrementoperation) { //statements }
for(declaration; incrementoperation; condition) { //statements }
for(initalization; condition; incrementoperation;) { //statements }
What is the 16-bit compiler allowable range for integer constants?
-3.4e38 to 3.4e38
-32767 to 32768
-32668 to 32667
-32768 to 32767
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 = 10, c = 10
a = 11, c = 10
a = 10, c = 11
a = 11, c = 11
Directives are translated by the
Pre-processor
Compiler
Linker
Editor
Which one of the following is a loop construct that will always be executed once?
for
while
switch
do while
The continue statment cannot be used with
for
while
do while
switch
C is a ____________ programming language
Object oriented Programming
Procedure oriented Programming
Structured programming language
Structure and Procedure Oriented Programming
