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?
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?
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) 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
Choose correct option for the above:
What will be the correct representation of statement stated above?
struct student
{
int mark1;
int mark2;
int mark3;
} sub1={67};
void main()
{
printf("%d", sub1.mark2);
}
What is the output of above code?
struct number
{
float x;
};
int main()
{
struct number n1,n2,n3;
n1.x=4;
n2.x=3;
n3=n1+n2;
return 0;
}
{
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?
#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);
}
struct box
{
int data;
struct Node *next;
};
void fun1(struct box* h)
{
if(h == NULL)
return;
fun1(h->next);
printf("%d ", h->data);
}
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:
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. _____
{
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?
int getCount(struct Node* head)
{
if (head == NULL)
return 0;
return 1 + getCount(head->next);
}
How many times getCount gets called ?