github

Made bySaurav Hathi

Test C/C++: Input and Output 1

Q1:

What is the value of x in this C code?

#include <stdio.h>

int main()

{

int x = 5 * 9 / 3 + 9;

printf("%d",x);

}

Tags:
Section:
Core Programming
Options:
Q2:

What is the output of this C code?

#include <stdio.h>

int main()

{

int x = 5.3 % 2;

printf("Value of x is %d", x);

}

Tags:
Section:
Core Programming
Options:
Q3:

What will be the output of this C code?

#include <stdio.h>

int main()

{

int x = 1, z = 3;

int y = x << 3;

printf("%d\n", y);

}

Tags:
Section:
Core Programming
Options:
Q4:

What is the output of this C code?

#include <stdio.h>

int main()

{

int a = 10, b = 5, c = 3;

b != !a;

c = !!a;

printf("%d %d", b, c);

}

Tags:
Section:
Core Programming
Options:
Q5:

What will be the output of this C code?

#include <stdio.h>

int main()

{

int x = 97;

char y = x;

printf("%c\n", y);

}

Tags:
Section:
Core Programming
Options:
Q6:

What is the output of this C code?

#include <stdio.h>

int main()

{

int a = 10, b = 10;

if (a = 5)

b--;

printf("a = %d, b = %d", a, b--);

}

Tags:
Section:
Core Programming
Options:
Q7:

What is the output of this C code?

#include <stdio.h>

int main()

{

int i = 0;

int x = i++, y = ++i;

printf("%d % d\n", x, y);

return 0;

}

Tags:
Section:
Core Programming
Options:
Q8:

What is the output of this C code?

#include <stdio.h>

int main()

{

int x = 97;

int y = sizeof(x++);

printf("X is %d", x);

}

Tags:
Section:
Core Programming
Options:
Q9:

What is the output of this C code?

#include <stdio.h>

int main()

{

int x = 4, y, z;

y = --x;

z = x--;

printf("%d %d %d", x,  y, z);

}

Tags:
Section:
Core Programming
Options:
Q10:

1.     What is the output of this C code?

#include <stdio.h>

int main()

{

int c = 2 ^ 3;

printf("%d\n", c);

}

Tags:
Section:
Core Programming
Options:
Q11:

What is the output of this C code?

#include <stdio.h>

int main()

{

unsigned int a = 10;

a = ∼a;

printf("%d\n", a);

}

Tags:
Section:
Core Programming
Options:
Q12:

What is the output of this C code?

#include <stdio.h>

int main()

{

int a = 2;

if (a >> 1)

printf("%d\n", a);

}

Tags:
Section:
Core Programming
Options:
Q13:

What is the output of this C code?

#include <stdio.h>

int main()

{

int a = 1, b = 2;

a += b -= a;

printf("%d %d", a, b);

}

Tags:
Section:
Core Programming
Options:
Q14:

What is the output of this C code?

#include <stdio.h>

int main()

{

int x = 0;

int *ptr = &x;

printf("%d\n", *ptr);

}

Tags:
Section:
Core Programming
Options:
Q15:

What is the output of this C code?

#include <stdio.h>

int main()

{

static int x = 3;

x++;

if (x <= 5)

{

printf("hi ");

main();

}

}

Tags:
Section:
Core Programming
Options:
Q16:

The output of the C code below is

#include <stdio.h>

int me()

{

printf("hello");

return 5;

}

int main()

{

int k = me();

printf(" %d", k);

}
 

Tags:
Section:
Core Programming
Options:
Q17:

What is the output of this C code?

#include <stdio.h>

int main()

{

int a[3] = {1, 2, 3};

int *p = a;

printf("%p\t%p", p, a);

}

Tags:
Section:
Core Programming
Options:
Q18:

What is the output of this C code?

#include <stdio.h>

int main()

{

char *s = "hello";

char *p = s;

printf("%p\t%p", p, s);

}

Tags:
Section:
Core Programming
Options:
Q19:

What is the output of this C code?

#include <stdio.h>

int main()

{

double *ptr = (double *)100;

ptr = ptr + 2;

printf("%u", ptr);

}

Tags:
Section:
Core Programming
Options:
Q20:

What will be the output of given C code?

#include <stdio.h>

int main()

{

int *p = (int *)2;

int *q = (int *)3;

printf("%d", p + q);

}

Tags:
Section:
Core Programming
Options: