What will be the output of the following C code?
#include
int main()
{
int i = -3;
int k = i % 2;
printf("%d\n", k);
}
- Compile time error
- -1
- 1
- Implementation defined
What will be the output of the following C code?
#include
int main()
{
int i = 3;
int l = i / -2;
int k = i % -2;
printf("%d %d\n", l, k);
return 0;
}
- Compile time error
- -1 1
- 1 -1
- Implementation defined
What will be the output of the following C code?
#include
int main()
{
int i = 5;
i = i / 3;
printf("%d\n", i);
return 0;
}
- Implementation defined
- 1
- 3
- Compile time error
What will be the output of the following C code?
#include
int main()
{
int i = -5;
i = i / 3;
printf("%d\n", i);
return 0;
}
- Implementation defined
- -1
- -3
- Compile time error
What will be the final value of x in the following C code?
#include
void main()
{
int x = 5 * 9 / 3 + 9;
}
- 3.75
- Depends on compiler
- 24
- 3
What will be the output of the following C code?
#include
void main()
{
int x = 5.3 % 2;
printf("Value of x is %d", x);
}
- Value of x is 2.3
- Value of x is 1
- Value of x is 0.3
- Compile time error
What will be the output of the following C code?
#include
void main()
{
int y = 3;
int x = 5 % 2 * 3 / 2;
printf("Value of x is %d", x);
}
- Value of x is 1
- Value of x is 2
- Value of x is 3
- Compile time error
What will be the output of the following C code?
#include
void main()
{
int a = 3;
int b = ++a + a++ + --a;
printf("Value of b is %d", b);
}
- Value of x is 12
- Value of x is 13
- Value of x is 10
- Undefined behaviour
What is the precedence of arithmetic operators (from highest to lowest)?
- %, *, /, +, –
- %, +, /, *, –
- +, -, %, *, /
- %, +, -, *, /
Which of the following is not an arithmetic operation?
- a * = 10;
- a / = 10;
- a ! = 10;
- a % = 10;
Which of the following data type will throw an error on modulus operation(%)?
- char
- short
- int
- float
Which among the following are the fundamental arithmetic operators, i.e, performing the desired operation can be done using that operator only?
- +, –
- +, -, %
- +, -, *, /
- +, -, *, /, %
What will be the output of the following C code?
#include
int main()
{
int a = 10;
double b = 5.6;
int c;
c = a + b;
printf("%d", c);
}
- 15
- 16
- 15.6
- 10
What will be the output of the following C code?
#include
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = a == (b + c);
printf("%d", d);
}
- Syntax error
- 1
- 10
- 5
What will be the output of the following C code?
#include
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y || z++;
printf("%d", z);
}
- 6
- 5
- 0
- Varies
What will be the output of the following C code?
#include
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y && z++;
printf("%d", z);
}
- 6
- 5
- 0
- Varies
What will be the output of the following C code?
#include
int main()
{
int x = 1, y = 0, z = 3;
x > y ? printf("%d", z) : return z;
}
- 3
- 1
- Compile time error
- Run time error
What will be the output of the following C code?
#include
void main()
{
int x = 1, z = 3;
int y = x << 3;
printf(" %d\n", y);
}
- -2147483648
- -1
- Run time error
- 8
What will be the output of the following C code?
#include
void main()
{
int x = 0, y = 2, z = 3;
int a = x & y | z;
printf("%d", a);
}
- 3
- 0
- 2
- Run time error
What will be the final value of j in the following C code?
#include
int main()
{
int i = 0, j = 0;
if (i && (j = i + 10))
//do something
;
}
- 0
- 10
- Depends on the compiler
- Depends on language standard
What will be the final value of j in the following C code?
#include
int main()
{
int i = 10, j = 0;
if (i || (j = i + 10))
//do something
;
}
- 0
- 20
- Compile time error
- Depends on language standard
What will be the output of the following C code?
#include
int main()
{
int i = 1;
if (i++ && (i == 1))
printf("Yes\n");
else
printf("No\n");
}
- Yes
- No
- Depends on the compiler
- Depends on the standard
Are logical operator sequence points?
- True
- False
- Depends on the compiler
- Depends on the standard
Do logical operators in the C language are evaluated with the short circuit?
- True
- False
- Depends on the compiler
- Depends on the standard
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
What will be the final value of d in the following C code?
#include
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = b + c == a;
printf("%d", d);
}
- Syntax error
- 1
- 5
- 10
What will be the output of the following C code?
#include
int main()
{
int a = 10, b = 5, c = 3;
b != !a;
c = !!a;
printf("%d\t%d", b, c);
}
- 5 1
- 0 3
- 5 3
- 1 1
Which among the following is NOT a logical or relational operator?
- !=
- ==
- | |
- =
What will be the output of the following C code?
#include
int main()
{
int a = 10;
if (a == a--)
printf("TRUE 1\t");
a = 10;
if (a == --a)
printf("TRUE 2\t");
}
- TRUE 1
- TRUE 2
- TRUE 1 TRUE 2
- Compiler Dependent
Relational operators cannot be used on ____________
- structure
- long
- strings
- float