CSE MCQs :: C-MCQs
-
What is the output of this C code?
int main()
{
char *p = NULL;
char *q = 0;
if (p)
printf(" p ");
else
printf("nullp");
if (q)
printf("q\n");
else
printf(" nullq\n");
} -
What is the output of this C code?
int main()
{
int i = 10;
void *p = &i;
printf("%d\n", (int)*p);
return 0;
} -
What is the output of this C code?
int main()
{
int i = 10;
void *p = &i;
printf("%f\n", *(float*)p);
return 0;
} -
What is the output of this C code?
int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int *j = (int*)malloc(sizeof(int));
*j = 10;
return j;
} -
What is the output of this C code?
int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int j = 10;
return &j;
} -
What is the output of this C code?
int main()
{
int *ptr, a = 10;
ptr = &a;
*ptr += 1;
printf("%d,%d/n", *ptr, a);
} -
Comment on the following?
const int *ptr; - Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0)?
-
What is the output of this C code?
int x = 0;
void main()
{
int *ptr = &x;
printf("%p\n", ptr);
x++;
printf("%p\n ", ptr);
}