Question 11
#include<stdio.h>
void f(int *p, int *q)
{
p = q;
*p = 2;
}
int i = 0, j = 1;
int main()
{
f(&i, &j);
printf(\"%d %d", i, j);
getchar();
return 0;
}
Question 12
void swap(int *px, int *py)
{
*px = *px - *py;
*py = *px + *py;
*px = *py - *px;
}
Question 13
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;
}
Question 14
#include<stdio.h>
int main()
{
int a = 12;
void *ptr = (int *)&a;
printf(\"%d\", *ptr);
getchar();
return 0;
}
Question 15
#include<stdio.h>
void swap (char *x, char *y)
{
char *t = x;
x = y;
y = t;
}
int main()
{
char *x = \"geeksquiz\";
char *y = \"geeksforgeeks\";
char *t;
swap(x, y);
printf(\"(%s, %s)\", x, y);
t = x;
x = y;
y = t;
printf(\"\\n(%s, %s)\", x, y);
return 0;
}
Question 16
#include <stdio.h>
int main()
{
int arr[] = {1, 2, 3, 4, 5};
int *p = arr;
++*p;
p += 2;
printf(\"%d\", *p);
return 0;
}
Question 17
#include <stdio.h>
void f(char**);
int main()
{
char *argv[] = { \"ab\", \"cd\", \"ef\", \"gh\", \"ij\", \"kl\" };
f(argv);
return 0;
}
void f(char **p)
{
char *t;
t = (p += sizeof(int))[-1];
printf(\"%s\\n\", t);
}
Question 19
Consider the C program shown below.
#include <stdio.h>
#define print(x) printf(\"%d \", x)
int x;
void Q(int z)
{
z += x;
print(z);
}
void P(int *y)
{
int x = *y + 2;
Q(x);
*y = x - 1;
print(x);
}
main(void)
{
x = 5;
P(&x);
print(x);
}
The output of this program is
Question 20
i) sizeof(int);
ii) sizeof(int*);
iii) sizeof(int**);
There are 43 questions to complete.