What is the output of this C code?
#include <stdio.h>
int main()
{
void *p;
int a[4] = {1, 2, 3, 4};
p = &a[3];
int *ptr = &a[2];
int n = (int*)p - ptr;
printf("%d\n", n);
}
What is the output of this C code?
#include <stdio.h>
int main()
{
int a[4] = {1, 2, 3, 4};
int *p = &a[1];
int *ptr = &a[2];
ptr = ptr * 1;
printf("%d\n", *ptr);
}
What is the output of this C code?
#include <stdio.h>
int main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d %d %d\n", k, *p, **m);
}
What is the output of this C code?
#include <stdio.h>
int main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d %d %d\n", k, *p, **p);
}
What is the output of this C code?
#include <stdio.h>
int main()
{
int k = 5;
int *p = &k;
int **m = &p;
**m = 6;
printf("%d\n", k);
}
Which of the following statements is true if we execute this C code?
#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
int **sptr = &ptr1; //-Ref
*sptr = ptr2;
}
What is the output of this C code?
#include <stdio.h>
int main()
{
int a[3] = {1, 2, 3};
int *p = a;
printf("%p %p", p, a);
}
What is the output of this C code?
#include <stdio.h>
int main()
{
int a[3] = {1, 2, 3};
int *p = a;
int **r = &p;
printf("%p %p", *r, a);
}
What is the output of this C code?
#include <stdio.h>
int main()
{
int one = 1, two = 2;
#ifdef next
one = 2;
two = 1;
#endif
printf("%d, %d", one, two);
}
What is the output of this C code?
#include <stdio.h>
#define fun(m, n) m ## n
int main()
{
printf("%s\n", fun(k, l));
}
What is the output of this C code?
#include <stdio.h>
#define fun(x, y) x / y + x
int main()
{
int i = -6, j = 3;
printf("%d\n",fun(i + j, 3));
return 0;
}
What is the output of this C code?
#include <stdio.h>
void fun();
int main()
{
#define max 10
fun();
return 0;
}
void fun()
{
printf("%d\n", max * 10);
}
What is the output of this C code?
#include <stdio.h>
#define SYSTEM 20
int main()
{
int a = 20;
#if SYSTEM == a
printf("HELLO ");
#endif
#if SYSTEM == 20
printf("WORLD\n");
#endif
}
What is the output of this C code?
#include <stdio.h>
#define COLD
int main()
{
#ifdef COLD
printf("COLD\t");
#undef COLD
#endif
#ifdef COLD
printf("HOT\t");
#endif
}
What is the output of this C code?
#include <stdio.h>
struct student
{
int no;
char name[20];
}
int main()
{
struct student s;
s.no = 8;
printf("hello");
}
What is the output of this C code?
#include <stdio.h>
struct
{
int k;
char c;
};
int main()
{
struct p;
p.k = 10;
printf("%d\n", p.k);
}
What is the output of this C code?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int p = 10;
int main()
{
struct p x = {1, 97};
printf("%f %d\n", x.f, p);
}
What is the output of this C++ code?
#include <iostream>
using namespace std;
struct p
{
char c;
int k;
float f;
};
int main()
{
struct p x = {c : 97, k : 1};
cout<<x.f;
}
What is the output of this C code?
#include <stdio.h>
struct student
{
char *name;
};
struct student s;
struct student foo(void)
{
s.name = "harry";
printf("%s ", s.name);
return s;
}
int main()
{
struct student m = foo();
printf("%s ", m.name);
m.name = "alan";
printf("%s ", s.name);
}
What’s the output of the following C code?
#include <stdio.h>
struct temp
{
int a;
} s;
void foo(struct temp s)
{
s.a = 10;
printf("%d ", s.a);
}
main()
{
foo(s);
printf("%d ", s.a);
}