Find the output of following code :
int main() { int i=-2; printf (“-i=%d”,-i); return b; }
–i=2
i=-2
–i=-2
–i=+2
The basic data type of C
Qualifier
Short is the qualifier and int is the basic data type
All of the mentioned
2
4
1
Depends on the system
What will be output if you will compile and execute the following c code?
int main(){ int a=5; float b; printf("%d",sizeof(++a+b)); printf(" %d",a); return 0;}
2 6
4 6
2 5
4 5
double
float
char
array
When the following piece of code is executed, what happens?
b = 3;a = b++;
a contains 3 and b contains 4
a contains 4 and b contains 4
a contains 4 and b contains 3
a contains 3 and b contains 3
-4
-2.8
+2.8
+3
Assignment Relational Arithmetic
Arithmetic Relational Assignment
Relational Arithmetic Assignment
Assignment Arithmetic Relational
int
long double
far double
What will be the output of the following code?
int main(){int x,y,z;x='1'-'0'; /* line-1 */y='a'-'b'; /* line-2 */z=x+y;printf("%d",z);}
0
Error because of incorrect line-1 only.
Error because of incorrect line-1 and line-2.
Error because of incorrect line-2 only.
What is the output of the following code?
int a = 5;printf("%d", a == 5);
5
Undefined
Either True or False
is less than or is more than
is equal or less or more
All of the above
*
+
++
&&
it Compare the variable a and the variable b are same.
The value of b is assigned to variable a but if b changes later, it will not effect the value of variable a.
The value of b is assigned to variable a but if b changes later, it will effect the value of variable a.
The value of variable a is assigned to variable b, and the value of variable b is assigned to variable a.
Binary operator
Unary operator
Ternary operator
int a = 10, b = 5;printf("%d", a / b);
0.5
15
results in a syntax error
output Infomax7
outputs garbage
outputs infomax and terminates abruptly
4 Bytes
8 Bytes
Depends on the system/compiler
Cannot be determined
&
||
!
print("Hello World");
echo("Hello World");
printf("Hello World");
None of these
print()
scanf()
input()
What will be output if you compile and execute the following ‘C’ code?
void main(){int i=4,x;x=++i + ++i + ++i;printf("%d",x);}
21
18
19
Compilation error
* / % + - =
= * / % + -
/ * % - + =
* % / - + =
3
It returns the size of the variable in bits
It returns the size of the variable in bytes
It returns the size of the variable in kilobytes
It returns the number of elements in an array
Decimal
Binary
Octal
Hexadecimal
What will be the output of the following program?
int main() { int x=5; printf(“%d %d %d”,x,x<<2,x>>2); }
1 20 5
5 1 20
5 20 1
20 1 5
Both can occur multiple times, but a declaration must occur first.
A definition occurs once, but a declaration may occur many times.
Both can occur multiple times, but a definition must occur first.
A declaration occurs once, but a definition may occur many times.
int num;
integer num;
num int;
num integer;
What is the output of the following code:
int x = 5;
printf("%d", x++);
6
float, double
short int, double, long int
float, double, long double
double, long int, float
%
#
N=m=0
Value+=10
mySize=x<y?9:11
Value=+=10
Logical Operator
Conditional Operator
typecast
Ternary
int x = 5;printf("%d", ++x);
7
-5
+5
8
10
20
None
<
=
>=
<=
What is the output of this statement
printf("%d", (a++));
The value of (a + 1)
Error message
Garbage
The current value of a
2.5
2.000000
2.500000
Addition, Division, Modulus
Addition, Modulus, Division
Multiplication, Substration, Modulus
Modulus, Multiplication, Substration
-3.4e38 to 3.4e38
-32767 to 32768
-32668 to 32667
-32768 to 32767
getchar()
gets()
cin.get()
printf("\n");
echo '\n';
printf('\n');
printf('\\n')
main(){ int a, b; a=b=4; b=a++; printf("%d %d %d %d", a++, --b, ++a, b--);}
5 3 7 3
Syntax error
5 4 5 3
6 2 6 4
real