Q1
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d", x++ + ++y);
return 0;
}
Q2
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a= 5;
cout << a++ << " " << ++a;
return 0;
}
Q3
What is the output of the following ccode?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
printf("%d", 3[arr]);
return 0;
}
Q4
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 10;
printf("%d %d %d", x, ++x, x++);
return 0;
}
Q5
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 5;
int y = x > 3 ? 10 : 20;
cout << y;
return 0;
}
Q6
What is the output of the following ccode?
#include <stdio.h>
int main() {
char c= 'A';
printf("%d", c);
return 0;
}
Q7
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 5, b= 10;
printf("%d", a& b);
return 0;
}
Q8
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 1;
cout << (x << 2);
return 0;
}
Q9
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 5;
if(x = 10)
printf("True");
else
printf("False");
return 0;
}
Q10
What is the output of the following ccode?
#include <stdio.h>
int main() {
printf("%d", sizeof(int));
return 0;
}
Q11
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a= 5, b= 10;
swap(a, b);
cout << a<< " " << b;
return 0;
}
Q12
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = -5;
printf("%u", x);
return 0;
}
Q13
What is the output of the following ccode?
#include <stdio.h>
int main() {
int arr[5] = {1, 2};
printf("%d", arr[3]);
return 0;
}
Q14
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
string s = "Hello";
cout << s[0] << s[4];
return 0;
}
Q15
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 10;
printf("%d %d", a, a++);
return 0;
}
Q16
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 0;
for(x = 0; x < 3; x++);
printf("%d", x);
return 0;
}
Q17
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 5;
cout << ++x * x++;
return 0;
}
Q18
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 5;
int b= ++a+ a++;
printf("%d", b);
return 0;
}
Q19
What is the output of the following ccode?
#include <stdio.h>
int main() {
char str[] = "Hello";
printf("%c", str[1]);
return 0;
}
Q20
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 10, y = 5;
cout << (x > y ? x : y);
return 0;
}
Q21
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", !x);
return 0;
}
Q22
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 10, b= 20;
printf("%d", a| b);
return 0;
}
Q23
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int arr[] = {1, 2, 3, 4, 5};
cout << *(arr + 2);
return 0;
}
Q24
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 8;
printf("%d", x >> 2);
return 0;
}
Q25
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x == 5);
return 0;
}
Q26
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 10;
int &y = x;
y = 20;
cout << x;
return 0;
}
Q27
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 1, b= 2, c= 3;
printf("%d", a&& b|| c);
return 0;
}
Q28
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x ^ x);
return 0;
}
Q29
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 5;
cout << (x & 1);
return 0;
}
Q30
What is the output of the following ccode?
#include <stdio.h>
int main() {
int i;
for(i = 0; i < 5; i++) {
if(i == 3) break;
}
printf("%d", i);
return 0;
}
Q31
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 10;
printf("%d", ~x);
return 0;
}
Q32
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 5, y = 10;
cout << (x += y);
return 0;
}
Q33
What is the output of the following ccode?
#include <stdio.h>
int main() {
printf("%d", 5 % 2);
return 0;
}
Q34
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 5;
printf("%d", a<< 1);
return 0;
}
Q35
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
bool x = true;
cout << x;
return 0;
}
Q36
What is the output of the following ccode?
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30};
printf("%d", sizeof(arr)/sizeof(arr[0]));
return 0;
}
Q37
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 0;
while(x < 5) {
if(x == 3) continue;
printf("%d", x);
x++;
}
return 0;
}
Q38
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 10;
int *p = &x;
cout << *p;
return 0;
}
Q39
What is the output of the following ccode?
#include <stdio.h>
int main() {
char c= 255;
c= c+ 5;
printf("%d", c);
return 0;
}
Q40
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++ + ++x);
return 0;
}
Q41
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a= 5, b= 10;
cout << (a< b? a++ : b++);
return 0;
}
Q42
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 15;
printf("%d", x & 8);
return 0;
}
Q43
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 5, b= 0;
printf("%d", a|| b);
return 0;
}
Q44
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 20;
x = x / 5 * 2;
cout << x;
return 0;
}
Q45
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 10, b= 5;
printf("%d", a!= b);
return 0;
}
Q46
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 7;
printf("%d", x ^ 3);
return 0;
}
Q47
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int arr[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
cout << arr[1][1];
return 0;
}
Q48
What is the output of the following ccode?
#include <stdio.h>
int main() {
int x = 10;
printf("%d", x > 5 && x < 15);
return 0;
}
Q49
What is the output of the following ccode?
#include <stdio.h>
int main() {
int a= 2, b= 3;
printf("%d", a* b+ a);
return 0;
}
Q50
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 10;
cout << (x == 10 ? "Yes" : "No");
return 0;
}
Q51
What is the output of the following C code?
#include <stdio.h>
int main() {
int x = 10;
int *p = &x;
printf("%d", *p);
return 0;
}
Q52
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30, 40};
int *p = arr;
printf("%d", *(p + 2));
return 0;
}
Q53
What is the output of the following C code?
#include <stdio.h>
int fact(int n) {
if(n <= 1) return 1;
return n * fact(n - 1);
}
int main() {
printf("%d", fact(4));
return 0;
}
Q54
What is the output of the following C code?
#include <stdio.h>
struct Point {
int x, y;
};
int main() {
struct Point p = {10, 20};
printf("%d", p.x + p.y);
return 0;
}
Q55
What is the output of the following C code?
#include <stdio.h>
int main() {
int x = 5;
int *p = &x;
*p = 10;
printf("%d", x);
return 0;
}
Q56
What is the output of the following C code?
#include <stdio.h>
int fib(int n) {
if(n <= 1) return n;
return fib(n-1) + fib(n-2);
}
int main() {
printf("%d", fib(5));
return 0;
}
Q57
What is the output of the following C code?
#include <stdio.h>
struct Student {
int roll;
char grade;
};
int main() {
struct Student s = {101, 'A'};
printf("%c", s.grade);
return 0;
}
Q58
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
int *p = &arr[2];
printf("%d", *p);
return 0;
}
Q59
What is the output of the following C code?
#include <stdio.h>
int sum(int n) {
if(n == 0) return 0;
return n + sum(n - 1);
}
int main() {
printf("%d", sum(5));
return 0;
}
Q60
What is the output of the following C code?
#include <stdio.h>
int main() {
int x = 10, y = 20;
int *p = &x, *q = &y;
printf("%d", *p + *q);
return 0;
}
Q61
What is the output of the following C code?
#include <stdio.h>
struct Book {
int pages;
float price;
};
int main() {
struct Book b = {300, 250.5};
printf("%.0f", b.price);
return 0;
}
Q62
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[] = {5, 10, 15};
printf("%d", 2[arr]);
return 0;
}
Q63
What is the output of the following C code?
#include <stdio.h>
int power(int base, int exp) {
if(exp == 0) return 1;
return base * power(base, exp - 1);
}
int main() {
printf("%d", power(2, 3));
return 0;
}
Q64
What is the output of the following C code?
#include <stdio.h>
int main() {
int x = 5;
int **pp = &(&x);
printf("%d", **pp);
return 0;
}
Q65
What is the output of the following C code?
#include <stdio.h>
struct Data {
int a;
int b;
};
int main() {
struct Data d = {5, 10};
struct Data *p = &d;
printf("%d", p->a);
return 0;
}
Q66
What is the output of the following C code?
#include <stdio.h>
int count(int n) {
if(n == 0) return 0;
return 1 + count(n / 10);
}
int main() {
printf("%d", count(12345));
return 0;
}
Q67
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30};
int *p = arr;
p++;
printf("%d", *p);
return 0;
}
Q68
What is the output of the following C code?
#include <stdio.h>
struct Node {
int data;
struct Node *next;
};
int main() {
struct Node n = {10, NULL};
printf("%d", n.data);
return 0;
}
Q69
What is the output of the following C code?
#include <stdio.h>
void modify(int *p) {
*p = 20;
}
int main() {
int x = 10;
modify(&x);
printf("%d", x);
return 0;
}
Q70
What is the output of the following C code?
#include <stdio.h>
int gcd(int a, int b) {
if(b == 0) return a;
return gcd(b, a % b);
}
int main() {
printf("%d", gcd(48, 18));
return 0;
}
Q71
What is the output of the following C code?
#include <stdio.h>
int main() {
int x = 10, y = 20;
int *p = &x;
p = &y;
printf("%d", *p);
return 0;
}
Q72
What is the output of the following C code?
#include <stdio.h>
struct Test {
int x;
int y;
};
int main() {
struct Test t = {0};
printf("%d %d", t.x, t.y);
return 0;
}
Q73
What is the output of the following C code?
#include <stdio.h>
int print(int n) {
if(n == 0) return 0;
printf("%d ", n);
return print(n - 1);
}
int main() {
print(3);
return 0;
}
Q74
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[3] = {1, 2, 3};
int *p = arr + 1;
printf("%d", p[-1]);
return 0;
}
Q75
What is the output of the following C code?
#include <stdio.h>
struct Point {
int x, y;
};
int main() {
struct Point p1 = {10, 20};
struct Point p2 = p1;
p2.x = 30;
printf("%d", p1.x);
return 0;
}
Q76
What is the output of the following C code?
#include <stdio.h>
int reverse(int n, int rev) {
if(n == 0) return rev;
return reverse(n/10, rev*10 + n%10);
}
int main() {
printf("%d", reverse(123, 0));
return 0;
}
Q77
What is the output of the following C code?
#include <stdio.h>
int main() {
int x = 10;
int *p = &x;
int **pp = &p;
printf("%d", **pp);
return 0;
}
Q78
What is the output of the following C code?
#include <stdio.h>
struct Rectangle {
int length;
int width;
};
int main() {
struct Rectangle r = {5, 10};
printf("%d", r.length * r.width);
return 0;
}
Q79
What is the output of the following C code?
#include <stdio.h>
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int main() {
int x = 5, y = 10;
swap(&x, &y);
printf("%d %d", x, y);
return 0;
}
Q80
What is the output of the following C code?
#include <stdio.h>
int mystery(int n) {
if(n < 10) return n;
return mystery(n/10) + n%10;
}
int main() {
printf("%d", mystery(1234));
return 0;
}
Q81
What is the output of the following C code?
#include <stdio.h>
int main() {
char str[] = "Hello";
char *p = str;
p += 2;
printf("%s", p);
return 0;
}
Q82
What is the output of the following C code?
#include <stdio.h>
struct Employee {
int id;
float salary;
};
int main() {
struct Employee e = {101, 50000.0};
struct Employee *p = &e;
printf("%d", p->id);
return 0;
}
Q83
What is the output of the following C code?
#include <stdio.h>
int ackermann(int m, int n) {
if(m == 0) return n + 1;
if(n == 0) return ackermann(m-1, 1);
return ackermann(m-1, ackermann(m, n-1));
}
int main() {
printf("%d", ackermann(1, 2));
return 0;
}
Q84
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30, 40};
int *p1 = arr;
int *p2 = arr + 3;
printf("%d", p2 - p1);
return 0;
}
Q85
What is the output of the following C++ code?
#include <iostream>
using namespace std;
struct Point {
int x = 10;
int y = 20;
};
int main() {
Point p;
cout << p.x + p.y;
return 0;
}
Q86
What is the output of the following C code?
#include <stdio.h>
int print(int n) {
if(n == 0) return 0;
printf("%d ", n % 10);
return print(n / 10);
}
int main() {
print(1234);
return 0;
}
Q87
What is the output of the following C code?
#include <stdio.h>
int main() {
int x = 5;
int *const p = &x;
*p = 10;
printf("%d", x);
return 0;
}
Q88
What is the output of the following C code?
#include <stdio.h>
typedef struct {
int num;
char ch;
} Data;
int main() {
Data d = {100, 'X'};
printf("%d %c", d.num, d.ch);
return 0;
}
Q89
What is the output of the following C code?
#include <stdio.h>
int tower(int n) {
if(n == 1) return 1;
return 2 * tower(n-1) + 1;
}
int main() {
printf("%d", tower(3));
return 0;
}
Q90
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[2][3] = {{1,2,3},{4,5,6}};
int (*p)[3] = arr;
printf("%d", (*p)[1]);
return 0;
}
Q91
What is the output of the following C code?
#include <stdio.h>
struct Complex {
int real, imag;
};
int main() {
struct Complex c1 = {3, 4}, c2;
c2 = c1;
c2.real = 5;
printf("%d", c1.real);
return 0;
}
Q92
What is the output of the following C code?
#include <stdio.h>
int binary(int n) {
if(n == 0) return 0;
return (n % 2) + 10 * binary(n / 2);
}
int main() {
printf("%d", binary(5));
return 0;
}
Q93
What is the output of the following C code?
#include <stdio.h>
void update(int x) {
x = 20;
}
int main() {
int a = 10;
updatea);
printf("%d", a);
return 0;
}
Q94
What is the output of the following C code?
#include <stdio.h>
struct Outer {
int x;
struct Inner {
int y;
} in;
};
int main() {
struct Outer o = {10, {20}};
printf("%d", o.in.y);
return 0;
}
Q95
What is the output of the following C code?
#include <stdio.h>
int sumArray(int *arr, int n) {
if(n <= 0) return 0;
return arr[n-1] + sumArray(arr, n-1);
}
int main() {
int a[] = {1, 2, 3, 4};
printf("%d", sumArray(a, 4));
return 0;
}
Q96
What is the output of the following C code?
#include <stdio.h>
int main() {
int x = 100;
int *p = &x;
printf("%d", (*p)++);
return 0;
}
Q97
What is the output of the following C code?
#include <stdio.h>
struct Time {
int hour, min, sec;
};
int main() {
struct Time t = {.sec = 30, .hour = 10};
printf("%d:%d", t.hour, t.min);
return 0;
}
Q98
What is the output of the following C code?
#include <stdio.h>
int isPalindrome(int n, int *rev) {
if(n == 0) return 1;
*rev = (*rev * 10) + (n % 10);
return isPalindrome(n / 10, rev);
}
int main() {
int rev = 0;
isPalindrome(121, &rev);
printf("%d", rev);
return 0;
}
Q99
What is the output of this C code?
#include <stdio.h>
int main() {
char *ptr = "Hello";
*ptr = 'M';
printf("%s", ptr);
return 0;
}
Q100
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[] = {5, 10, 15, 20};
int *p = arr;
printf("%d", *(p + 3) - *(p + 1));
return 0;
}