WorksheetsC programming
Total questions: 65
Worksheet time: 2hrs 10mins
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
Which one of the following is a loop construct that will always be executed once?
for
while
switch
do while
What will the result of 'num' variable after execution of the following statements?
int num = 58;
num % = 11;
3
5
8
11
What will the result of num1 variable after execution of the following statements?
int j = 1, num1 = 4;
while (++j <= 10)
{
num1++;
}
11
12
13
14
What will be the output of the C code?
Hello World! x;
Hello World! followed by a junk value
Compile time error
Hello World!
What will be the output of the following C code?
2
8
9
10
What will be the output of the following C code?
3 2 3
2 2 3
3 2 2
2 3 3
What will be the output of the following C code?
Run time error
7
8
Depends on compiler
What will be the output of the following C code?
True
False
True False
No Output
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
1
2
1 2
Run Time Error
What will be the output of the following C code?
Hi is printed 9 times
Hi is printed 8 times
Hi is printed 7 times
Hi is printed 6 times
What will be the output of the following C code?
H
H is printed infinite times
Compile time error
Varies
What will be the output of the following C code?
hello 5
Error
Nothing
Junk value
What will be the output of the following C code?
Undefined behavior
Output will be 3
Output will be 6
Output will be 5
What will be the output of the following C code
6 -6 0 0
6 -5 0 1
-6 -6 0 1
6 -6 0 1
#include statement must be written __________
Before main()
Before any scanf() / printf()
After main()
It can be written anywhere
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");
}
hi
hello
no
error
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");
}
inside if
inside else if
inside else
compile time error
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");
}
Depends on the compiler
No print statement
True
False
The switch statement takes a given integer value then seeks a matching value among a number of _______ statements.
break
case
switch
goto
How many loops are there in C
1
3
2
4
Which of the following is an exit control statement
for
while
do while
continue
The output of the following segment is
int k, n=20;
k=(n>5?(n<=10?100:200):500);
printf("%d",n);
100
200
300
20
The value of i after the execution of the following segment is
i = 2;
for( i=0; i>10; i=i+1);
1
2
0
11
Which of the following is not a correct variable type?
float
real
int
double
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=1, b=1
a=2, b=1
a=1, b=2
a=2, b=2
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);
}
0
1
2
compile time error
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;
}
}
yes
no
yes no
compile time error
Is it possible to run program without main() function?
yes
no
may be
How many main() function we can have in our project?
1
2
no limit
depends on the program
int x = 10;
int main()
{
int x = 0;
printf("%d",x);
return 0;
}
10
0
compile error
undefined
What should be the output:
int main()
{
int a = 10/3;
printf("%d",a);
return 0;
}
3.33
3.0
3
0
Which of the following correctly shows the hierarchy of arithmetic operations in C?
/ + * -
* - / +
+ - / *
/ * + -
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 logical operator?
&
&&
||
!
When does the code block following while(x<100) execute?
When x is less than one hundred
When x is greater than one hundred
When x is equal to one hundred
while it wishes
Input/output function prototypes and macros are defined in which header file?
conio.h
stdlib.h
stdio.h
dos.h
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()
What punctuation is used to signal the beginning and end of code blocks?
{ }
-> and <-
BEGIN and END
( and )
The "\n" character does which of the following operations?
Double line spacing
Character deletion
Character backspace
Places cursor on the next line
Is the syntax for the following C statement correct?:
scanf("%d", input);
True
False
Which arithmetic operator in C returns the integer remainder of the result of dividing its first operand by its second?
%
/
\
*
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--);
}
5 3 73
5 4 5 3
6 2 6 4
Syntax Error
Find error/ output in following code
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
Find error/output in following code
int main ()
{
int m = -10,n =20;
n = ( m < 0) ? 0 : 1;
printf ( " %d %d ", m,n ) ;
}
-10 0
10 20
20 -10
0 1
Find Error/ output in following code
int main ()
{
int x = 1;
While (x= 0)
printf (" Hello");
}
Hello
No output
Infinite time Hello display
Error in code
1. What will be the output of following program?
1 2 3 4 5
1 2 3 4
6
5
What will be the output of the program?
Compiler error
10 10 10 10 10
11 12 13 14 15
None of the above
What will be the output of the program?
No Output
32 33 34
32 33 34 35
Compiler error
What is the output of this program?
32
33
30
No Output
Which of the given statement is true about the given code ?
RABBIT is printed unlimited number of times
RABBIT
Compiler error
None of the above.
What will be the output of following program ?
RABBIT
RABBIT is printed unlimited number of times.
No Output
Compiler error.
How many times i value is checked in the following C code?
2
3
4
1
How many times i value is checked in the following C code?
2
3
4
1
What will be the output of following program ?
H
H is printed infinite times
Compile time error
No output
Which of the following is not a valid variable name declaration?
int a3;
int 3a;
int _A3;
int a_3
All keywords in C are in ____________
Lowercase
Uppercase
Camelcase
None of these
A translator which reads an entire program written in a high level language and converts it into machine language code is:
Assembler
Compiler
Linker
Loader
Diamond shaped symbol is used in flowcharts to show the-
decision box
statement box
error box
if-statement box
Which is valid C variable declarations?
int my_num = 100,000;
int my_num = 100000;
int my num = 1000;
int $my_num = 10000;
Which is correct with respect to size of the data types?
char > int > float
int > char > float
char < int < double
double > char > int
The functions printf() and scanf() are defined in which of the following library file:-
math.h
conio.h
stdio.h
stdlib.h
Who developed C language
Dennis Ritchie
Bill Gates
Dennis Lilly
Stephen
