0% found this document useful (0 votes)
13K views4 pages

Program Java

The document contains 5 code snippets in C language and questions about their outputs. The first code snippet defines a function pointer, assigns it to a function, and calls the function through the pointer. It would print "10" as the output. The second code snippet defines a function that takes a function pointer as a parameter. It passes a function pointer to myfoo() and calls it, printing "11" as the output. The third code snippet increments a pointer variable after assigning it to another pointer variable. It would print "1" as the difference between the two pointers. The fourth code snippet uses the comma operator in a function call. It would print "-5" as the value of

Uploaded by

Abdul Saleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13K views4 pages

Program Java

The document contains 5 code snippets in C language and questions about their outputs. The first code snippet defines a function pointer, assigns it to a function, and calls the function through the pointer. It would print "10" as the output. The second code snippet defines a function that takes a function pointer as a parameter. It passes a function pointer to myfoo() and calls it, printing "11" as the output. The third code snippet increments a pointer variable after assigning it to another pointer variable. It would print "1" as the difference between the two pointers. The fourth code snippet uses the comma operator in a function call. It would print "-5" as the value of

Uploaded by

Abdul Saleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

55) What is the output of this C code?

#include <stdio.h>

void f(int);

void (*foo)(void) = f;

int main(int argc, char *argv[])

foo(10);

return 0;

void f(int i)

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

a) Compile time error


b) 10
c) Undefined behaviour
d) None of the mentioned

56) What is the output of this C code?

#include <stdio.h>

void f(int (*x)(int));

int myfoo(int);

int (*foo)() = myfoo;

int main()

f(foo);
}

void f(int(*i)(int ))

i(11);

int myfoo(int i)

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

return i;

a) 10 11
b) 11
c) 10
d) Undefined behavior

57) What is the output of this C code?

#include <stdio.h>

void main()

int x = 4;

int *p = &x;

int *k = p++;

int r = p - k;

printf("%d", r);

a) 4
b) 8
c) 1
d) Run time error
58) What is the output of this C code?

#include <stdio.h>

void main()

int a = -5;

int k = (a++, ++a);

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

a) -4
b) -5
c) 4
d) -3

59) What is the output of this C code?

#include <stdio.h>

int x = 0;

void main()

int *const ptr = &x;

printf("%p\n", ptr);

ptr++;

printf("%p\n ", ptr);

a) 0 1
b) Compile time error
c) 0xbfd605e8 0xbfd605ec
d) 0xbfd605e8 0xbfd605e8
60)

You might also like