Operators
- What will be the final value of n4 in the following C code?
#include <stdio.h>
int main()
{
int n1 = 8, n2 = 4, n3 = 4;
int n4;
n4 = n2 + n3 == n1;
printf("%d", n4);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
1
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num = 12;
if (num == num--)
printf("TRUE 1\t");
num = 10;
if (num == --num)
printf("TRUE 2\t");
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
This is a sequence point problem and hence the result will be implementation dependent.
- What is the difference between the following 2 codes?
//Program 1
#include <stdio.h>
int main()
{
int n3, n1 = 2, n2 = 3;
n3 = n1++ + ++n2;
printf("%d %d %d", n3, n1, n2);
}//Program 2
#include <stdio.h>
int main()
{
int n3, n1 = 2, n2 = 3;
n3 = n1++ + +++n2;
printf("%d %d %d", n3, n1, n2);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Program 2 has syntax error, program 1 is not
- Relational operators cannot be used on ____________.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
structure
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int n1 = 15;
int n2 = 16;
n1 < n2 ? n1 = n1 + 1 : n2 = n2 + 1;
printf("%d", n1);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Compilation Error
main.c: In function ‘main’:
main.c:6:36: error: lvalue required as left operand of assignment
n1 < n2 ? n1 = n1 + 1 : n2 = n2 + 1;