C Output Questions

1. Find Error/Output in follwing code:
2. ```                            ```
int main() {
int x = 0, y = 0;
if(x > 0)
if(y > 0)
printf("True");
else
printf("False");
}
```                            ```
1. No Output
2. True
3. False
4. Error because of dangling else problem
A
Explanation:

1. Find Error/Output in follwing code:
2. ```                            ```
main() {
int i = 2, *j;
j = &i;
printf("%d", i**j*i+*j);
}
```                            ```
1. Syntax error due to Invalid expression in printf
2. Print junk value
3. 16
4. 10
D
Explanation:

1. Find Error/Output in follwing code:
2. ```                            ```
int main() {
int x,y,z;
x = '1'-'0'; /* line-1 */
y = 'a'-'b'; /* line-2 */
z = x + y;
printf("%d",z);
}
```                            ```
1. 0
2. Error because of incorrect line-1 only.
3. Error because of incorrect line-1 and line-2.
4. Error because of incorrect line-2 only.
A
Explanation:

1. Find Error/Output in follwing code:
2. ```                            ```
void fn() {
int a = 10;
static int b = 20;
printf("a = %d b = %d", ++a, ++b);
}
int main() {
fn();
fn();
return 0;
}

```                            ```
1. a = 11 b = 21 a = 11 b = 22
2. a = 11 b = 21 a = 11 b = 22
3. a = 11 b = 21 a = 11 b = 22
4. a = 11 b = 21 a = 11 b = 22
B
Explanation:

1. Find Error/Output in follwing code:
2. ```                            ```
void main ( )
{
char *P = "ayqm" ;
char c;
c = ++*p ;
printf ("%c", c);
}
```                            ```
1. a
2. 0x56FA
3. m
4. y
A
Explanation:

1. Find Error/Output in follwing code:
2. ```                            ```
void main()
{
int x=10,*y,**z;
y=&x;
z=&y;
printf(\"%d%d%d\",*y,**z,*(*z));
}
```                            ```
1. 101010
2. 100xaa54f10
3. Run time error
4. No Output
A
Explanation:

1. Find Error/Output in follwing code:
2. ```                            ```
void main()
{
int a = 1, b=2, c=3;
char d = 0;
if(a,b,c,d)
{
printf("EXAM");
}
}
```                            ```
1. No Output and No Error
2. EXAM
3. Run time error
4. Compile time error
A
Explanation:
Print statement will not execute because if condition return false. Value of variable d is 0.

1. Find Error/Output in follwing code:
2. ```                            ```
void main()
{
int a = 1, b=2, c=3;
if(a,b,c)
{
printf("EXAM");
}
}
```                            ```
1. EXAM
2. No Output
3. Run time error
4. None of the above