70 questions
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
#include<stdio.h>
int main()
{
float a=0.7;
if(a<0.7)
{
printf("C");
}
else
{
printf("C++");
}
}
C
C++
Compilation Error
None of the these
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
#include<stdio.h>
int main()
{
int a=2,b=7,c=10;
c=a==b;
printf("%d",c);
}
0
7
2
Compilation error
What is the output of C Program.?
int main()
{
int a=5;
while(a >= 3);
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed infinite times
None of 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
What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
}
while(a <= 30);
return 0;
}
32
33
30
No Output
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;
}
No Output
32 33 34
32 33 34 35
Compiler error
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.
What is the output of C Program.?
int main()
{
int k;
for(;;)
{
printf("TESTING\n");
break;
}
return 0;
}
No Output
TESTING
Compiler error
None of the above
What is the way to suddenly come out of or Quit any Loop in C Language.?
continue; statement
break; statement
leave; statement
quit; statement
Choose correct C while loop syntax.
while(condition) { //statements }
{ //statements }while(condition)
while(condition); { //statements }
while() { if(condition) { //statements } }
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 output of C Program.?
int main()
{
int a=5;
while(a==5)
{
printf("RABBIT");
break;
}
return 0;
}
RABBIT is printed unlimited number of times
RABBIT
Compiler error
None of the above.
What is the output of C Program.?
int main()
{
int a=5;
while(a=123)
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed unlimited number of times.
Compiler error.
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf("In while loop\n");
} while (i < 3);
}
In while loop
In while loop
In while loop
In while loop
In while loop
Depends on the compiler
Compile time error
Every C Program Statement must be terminated with a
.
#
;
!
What does the following code fragment write to the monitor?
Under
Over
Under the limit
Over the limit
What does the following code fragment write to the monitor?
Under
Over
Under the limit
Over the limit
Evaluate(to true or false) each of the following expressions:
(1) 14 <= 14
(2) 14 < 14
false false
true true
true false
false true
When applied to a variable, what does the unary "&" operator yield?
The variable's address
The variable's right value
The variable's binary form
The variable's value
The operator "&" is used for
Bitwise AND
Bitwise OR
Logical AND
Logical OR
The operator "&" is used for
Bitwise AND
Bitwise OR
Logical AND
Logical OR
The size of a character variable in C is
8 bytes
4 bytes
2 bytes
1 byte
The words if, else, auto, float etc. have predefined meaning and users cannot use them as variables.
These words are called
keywords
identifier
data types
constant
Which operators are used to compare the values of operands to produce logical value in C language
Logical operator
Relational operator
Assignment operator
None of the above
An opertor used to check a condition and select a value depending on the value of the condition is called
Logical operator
Decrement operator
Conditional or Ternary operator
Bitwise operator
Which operators perform operations on data in binary level?
Logical operator
Bitwise operator
Additional opertors
None of the above
What is the value of this expression using integer arithmetic:
7 / 4
1
2
1.75
Determine the value of this expression using integer arithmetic:
5 % 7
0
2
5
Determine the value of b in this code fragment:
int a=3, b;
b=++a;
3
4
2
Determine the value of the expression using integer arithmetic:
6 * 9 % 3 / 2
2
0
18
Determine the value of a in the second line of the code fragment:
int a=1, b=2;
a=b--;
1
0
2
Which line of code is correct for the statement:
Read in a value for the integer variable num.
printf("%d", &num);
scanf("%d", num);
scanf("%d", &num);
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");
This is True
This is False
What symbol is used in conditional operators for AND:
AND
&&
&
What will be printed on the screen from this fragment:
int num=0;
printf("%d", ++num)
0
1
2
What is the abbreviated way to write this assignment statement:
total=total+num;
t=t+n;
total+=num
total=(total+num)
C language is a
structured program
object oriented program
oriented program
basic program
Relational operator
+
=
==
/
a=2;b=6; (a<b):10:15
10
15
2
6
After first pass the answer for x=5-6/3+8*2-1
5-2+8*2-1
5-6/3+16-1
5-2+16-1
-1/3+8*2-1
%s indicates in scanf statement
to get an integer
to get a character
to get a string
to get a real no.
What is the data type use for whole number?
%ld
%f
%lf
What operator that will be perform last in a given equation?
+
/
%
What format specifier is use for double data type?
%lf
%d
%f
Which should be the printf statement of the following program:
void main()
{
int age = 10;
printf...
}
printf("I am %d years old.\n");
printf("I am %f years old.\n", age);
printf("I am %s years old.\n");
printf("I am %d years old.\n", age);
Check the following code segment and try to predict what's going to happen?
#include <stdio.h>
int main(){
int x=++2;
printf("%d",x);
return 0;
}
3 will be printed on compilation and execution.
2 will be printed on compilation and execution.
compilation error - "Ivalue required".
runtime error.
Libray function getch() belongs to which header file?
stdio.h
conio.h
stdlib.h
stdlibio.h
What is the value of X in the sample code given below?
X = ( 2 + 3) * 2 + 3;
10
13
25
28
What value will be stored in z if the following code is executed?
x = 5 , y = -10, a = 4, b = 2;
z = x+++++y * b/a;
-2
0
1
2
#include <stdio.h>
void main()
{
int k = 8;
int x = 0 == 1 && k++;
printf(“%d%d\n”, x, k);
}
a) 0 9
b) 0 8
c) 1 9
d) 1 8
#include <stdio.h>
int main()
{
int x = 2, y = 2;
x /= x / y;
printf(“%d\n”, x);
return 0;
}
a) 2
b) 0.5
c) 1
d) Undefined behaviour shown
#include <stdio.h>
int main()
{
int x = 2, y = 1;
x *= x + y;
printf("%d\n", x);
return 0;
}
a) 6
b)5
c) Undefined behavior shown
d) Compilation time error
#include<stdio.h>
void main()
{
int a=5;
int b=6;
a++;
b++;
printf("%d %d",a,b);
}
5 6
6 7
5 7
Compilation Error
#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("SKCT");
}
return 0;
}
A.Infinite times
B. 11 times
C. 0 times
D.10 times
#include<stdio.h>
int main()
{
int i=0;
for(; i<=5; i++);
printf("%d", i);
return 0;
}
Compilation Error
6
012345
12345
#include<stdio.h>
int main()
{
float a = 0.7;
if(0.7 > a)
printf("Hi\n");
else
printf("Hello\n");
return 0;
}
A.Hi
B. Hello
C. Hi Hello
D.None of above
#include<stdio.h>
int main()
{
int k, num = 30;
k = (num < 10) ? 100 : 200;
printf("%d\n", num);
return 0;
}
A.200
B. 30
C. 100
D.500
#include<stdio.h>
int main()
{
int a = 300, b, c;
if(a >= 400)
b = 300;
c = 200;
printf("%d, %d, %d\n", a, b, c);
return 0;
}
A.300, 300, 200
B. Garbage, 300, 200
C. 300, Garbage, 200
D.300, 300, Garbage
#include<stdio.h>
int main()
{
char j=1;
while(j < 5)
{
printf("%d, ", j);
j = j+1;
}
printf("\n");
return 0;
}
1 2 3 ... 127
1 2 3 ... 255
1 2 3 ... 127 128 0 1 2 3 ... infinite times
1, 2, 3, 4
The modulus operator cannot be used with a long double.
True
False