#include<stdio.h>

void xy (int x, int y) {

int *ptr;

x = 0;

ptr = &x;

y = *ptr;

*ptr = 2;

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

}

void main()

{

xy(0,2);

}

What is the output of the above program?

0,2
2,0
2,2
0,0
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
#include<stdio.h>

typedef int (*fun)(int);

int fun2(int a)

{

return (a+1);

}

int main()

{

fun p1 = NULL, p2 = NULL;

p1 = &fun2; /* (1) */

p2 = fun2; /* (2) */

(*p1)(5); /* (3) */

p2(5); /* (4)*/

return 0;

}

Which of the following lines is correct about the above code?

Line with comment (2) will give a compile error.

Lines with (1) & (3) will give compile error.
Lines with (2) & (4) will give compile error.
No compile error and program will run without any issue
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
#include<stdio.h>

int arr[3][3][3];

int main()

{

arr[2][2][2] = 22;

return 0;

}

Which of the given printf statement(s) would be able to print a[2][2][2]

1) printf("%d",arr[2][2][2]);

2) printf("%d",*(*(*(arr+2)+2)+2));

3) printf("%d",(*(*(arr+2)+2))[2]);

4) printf("%d",*((*(arr+2))[2]+2));

1,2
1,2,3
1,2,3,4
Compiler error
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Choose correct option among the following about 1,2,3 and 4 statements

1) A function pointer points to code

2) A function pointer points to data

3) We can allocate &/or deallocate memory using function pointers

4) We can’t allocate &/or deallocate memory using function pointers

1,4
2,3
1,3
2,4
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
int *(*func())();

Choose correct option for the above:

func is pointer to function returning pointer to int
func is function returning a function returning pointer to int
func is pointer to a function returning a function returning pointer to int
func is function returning pointer to function returning pointer to int
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
p is an array of 2 pointers, pointing to a functions which takes input arguments as integer pointer and an integer and returns nothing.

What will be the correct representation of statement stated above?

void (*p)[2](int*, int);
*(p[2]) (int*, int);
void (*p[2])(int*, int);
int (*p)[2](int, int*);
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
#include<stdio.h>

struct student

{

int mark1;

int mark2;

int mark3;

} sub1={67};

void main()

{

printf("%d", sub1.mark2);

}

What is the output of above code?

67
0
Compiler error
Garbage value
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What will be the output of the following C program?

struct number

{

float x;

};

int main()

{

struct number n1,n2,n3;

n1.x=4;

n2.x=3;

n3=n1+n2;

return 0;

}

7
7.0
Compiler error
0
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
int f(int x, int *py, int **ppz)

{

int y, z;

**ppz += 1;

z = **ppz;

*py += 2;

y = *py;

x += 3;

return x + y + z;

}

void main()

{

int c, *b, **a;

c = 4;

b = &c;

a = &b;

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

return 0;

}

What is the output of the above C code?

18
19
20
21
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What is the output of the following program?


#include<stdio.h>

#include<string.h>

int main()

{

char *first[]={"Gokulan","raudra","girish","anand"};

char **second[]={(first+3),(first+2),(first+1),(first+0)};

char ***third=second;

printf("%s",**++third);

printf("%s",*--*++third+3);

printf("%s",third[-1][-1]+1);

}

girishkulanudra
girishulanaudra
raudraulangirish
raudrakulananand
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What does the following function do for a given Linked List with the first node as head?

struct box

{

int data;

struct Node *next;

};


void fun1(struct box* h)

{

if(h == NULL)

return;

fun1(h->next);

printf("%d ", h->data);

}

Prints all nodes of linked lists
Prints all nodes of linked list in reverse order
Prints alternate nodes of Linked List
Prints alternate nodes in reverse order
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Which of the following is correct if:

int r=10;

int *q = &r;

int **rq = &q;

If we print the following expressions, then value of which options among the following options will produce same value:

  1. r, **rq
  2. &r, q, *rq
  3. rq, &q
  4. *rq, &q,
Only 1
1 and 2
1, 2, 3
1,2,3,4
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
State true or false:

Accessing an element in an Linked list is fast, while array takes linear time, so it is quite a bit slower in case of array. _____

True
False
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
void fun(struct Node** ref, int d)

{

struct Node* n = (struct Node*) malloc(sizeof(struct Node));

n ->data = d;

n ->link = (*ref);

(*ref) = n;

}

Here, ref is the reference of the head node of the linked list.

Assuming main function and struct Node having two elements data and *link is given, what does the above fun do, when called in main?

Insert a node at any position of linked list
Insert a node in the starting position of a linked list
Insert a node at the end of linked list
Insert a node after 1st node of linked list
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Given a linked list having N number of nodes, the following function is called to count the number of nodes in it.

int getCount(struct Node* head)

{

if (head == NULL)

return 0;

return 1 + getCount(head->next);

}

How many times getCount gets called ?

N
N+1
N^2
N-1
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66