Operators
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int n = 12;
int num = 2 == 3 && n++;
printf("%d %d", num, n);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
0 12
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
char p = 'p';
int q = (p % 10)++;
printf("%d\n", q);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Compilation Error
main.c: In function ‘main’:
main.c:5:25: error: lvalue required as increment operand
int q = (p % 10)++;
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 4;
int q = p == 3 ? getchar(): 3;
printf("%d\n", q);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
Ascii value of character getchar function returns
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 4;
int q = 1;
int R = (q == 1) ? p :(p > q) ? (q = 1): p;
printf("%d\n", q);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
1
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 2;
short int k = 3;
float var = 4;
if (sizeof((p == 3) ? var : k) == sizeof(float))
{
printf("Float\n");
}
else if (sizeof((p == 3) ? var : k) == sizeof(short int))
{
printf("Short int\n");
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Float