Predict the output of the following coding questions of C language:

1. Find the output of the following code?
void main()
{
int a[2][3] = {1, 2, 3, 4, 5};
int i = 0, j = 0;

for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d\t", a[i][j]);
}

2. Find the output of the following code?
void main()
{
int a[2][2] = {{2,3},{1,6}};
printf("%d", &a[0][1] - &a[0][0]);
}

3. What is the size of the array arr if it is declared as, float arr[3][2][2]?


4. Find the output of the following code?
void main()
{
char data[2][3][2]={0,1,2,3,4,5,6,7,8,9,10,11};
printf("%o",data[0][2][1]);
}

5. Find the output of the following code?
void main()
{
short num[3][2]={3,6,9,12,15,18};
printf("%d %d",*(num+1)[1],**(num+2));
}

6. Find the output of the following code?
void main()
{
char *ptr="c programming";
printf("%c",3[ptr]);
}


7. Find the output of the following code?
void main()
{
int array[2][3]={5,10,15,20,25,30};
int (*ptr)[2][3]=&array;
printf("%d\t",***ptr);
printf("%d\t",***(ptr+1));
printf("%d\t",**(*ptr+1));
printf("%d\t",*(*(*ptr+1)+2));
}

8. Find the output of the following code?
void main()
{
int arr[][3]={{1,2},{3,4,5},{5}};
printf("%d %d %d",sizeof(arr),arr[0][2],arr[1][2]);
}

9. Find the output of the following code?
void main()
{
char arr[20]="Mahendra Singh Dhoni";
printf("%d",sizeof(arr));
}


10. Find the output of the following code?
void main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m; i = ++a[1]; j = a[1]++;
m = a[i++]; printf("%d, %d, %d", i, j, m);
}

11. What is the output of the following program?
int a[6] = {2, 7, 3, 1, 5, 9};
printf(“%d”,a[5] + 6);

12. What will be the output of the following code ?
void main()
{
int a[5]={3,5,6,2,7};
int i=3;
if(a[i]==a[i+3])
printf("true");
else
printf("false");
}

13. What will be the output of the following code ?
void main()
{
int a[5] = {5,7,3,1,2};
a[2]=a[1];
a[1]=a[3];
a[2]=a[2]+a[3];
printf("%d\t%d", a[1],a[2]);
}


14. Write the output of the following code?
void main()
{
int a[3][2] = {10. 20, 30, 40, 50, 60};
printf(“%d”, a[0][4]);
}

15. Write the output of the following code?
void main()
{
int x[10] = {5};
printf(“%3d%3d”, x[1], x[9]);
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: