You are on page 1of 18

C Programming

➢ By Mallesham Devasane
➢ Contact: 9911691155
#21 Rank
13th July to 31st July ( 11:00 AM to 12:30 PM)
Predict the output of the following program:
int A(int x, int *py, int **ppz) 1
{
int y=5, z=1;
**ppz += **ppz;
z = **ppz;
*py += **ppz;
y += *py;
x += 3;
return x + y + z;
}
void main()
{
int x=5, *y=&x, **z=&y;
printf("%d ", A(x,y,z));
}
a) --
b) --
c) --
d) --
Predict the output of the following program: 2
void A(char *x, char *y){
char *temp=x;
x=y;
y=temp;
}
void main(){
char *x="Hello",*y="Hi";
A(y,x);
printf("%s,%s",x,y);
}
a) Hello,Hi
b) Hi,Hello
c) Compilation Error
d) None of the above
Predict the output of the following program:
#include <stdio.h>
3
void main()
{
int x[] = {10, 20, 30, 40, 50};
int *y = x;
++*y;
*y++;
y += 1;
printf("%d", y[-1]);
}
a) 30
b) 40
c) 10
d) 20
e) 11
What is the return value of the following function for the call ABC(“Hey there”)? 4
int ABC(char *s){
char *p = s;
while (*p != '\0’) p++;
return p - s;
}

a) 9
b) 10
c) 8
d) None of the above
Predict the output for the following code: 5
void fun(int **x){
int i=10;
int *p=&i;
x=&p;
printf("%d ", x[0][0]);
}
void main(){
int a[][3]={1,2,3,4,5,6};
fun(a);
printf("%d",a[0][0]);
}
a) 10 1
b) 1 1
c) Compilation Error
d) None of the above
Question: Predict the output of the following program: 6
void foo1(char *x[]){
printf("%s",x[0]);
}
void foo2(char **x){
x=x+1;
printf("%s",x[0]);
}
void main(){
char *x[] = {"GATE", "EXAM", "WORK", "HARD"};
foo1(x);
foo2(x);
}
a) GATEEXAM
b) EXAMGATE
c) GATEATE
d) ATEGATE
Predict the output of the following program: 7
void main(){
int x[][3] = {10, 20, 30, 40, 50, 60};
int (*y)[3] = x;
printf("%d %d ", (*y)[1], (*y)[2]);
++y;
printf("%d %d", (*y)[1], (*y)[2]);
}

a) 20 30 40 50
b) 20 30 50 60
c) 40 50 60 60
d) None of the above
Predict the output of the following program: 8
char *x[]={"GATE","EXAM","WORK","HARD"};
char **y[]={x+3,x+2,x+1,x};
char ***z=y;
void main()
{
printf("%s",**++z);
printf("%s",*--*++z+3);
}
a) WORKE
b) EXAME
c) HARDD
d) None of the above
Predict the return value of following function for the call ABC(“when”, “what”)?
9
int ABC(char *x, char *y)
{
for ( ; *x == *y; x++, y++)
if (*x == '\0')
return 0;
return *x - *y;
}
a) 6
b) 4
c) -6
d) -4
e) None of the above
Is it a good practice to write the following code? 10
char *abc(){
char x='c';
x++;
return &x;
}
void main(){
char *x=abc();
printf("%c",*x);
}

a) Yes
b) No
Today
1) YouTube TOC Live Class (7AM – 9AM)
2) Ultimate Course on C Prog. (11:00 AM – 12:30 PM)
3) Mini GATE Test 10 (2 PM - 3 PM)
4) DPP11 on C (Arrays & Pointers) (3:30 PM - 4:30 PM)
5) Ask DEVA Sir (Session 2) (5PM-6PM)
THANK YOU

You might also like