0% found this document useful (0 votes)
46 views5 pages

Test Your C Skills Class: Roll No: 1. What Will Be Output of Following C Code?

The document tests C programming skills through a series of code snippets and their expected outputs. It contains 10 multiple choice questions, each with a short code sample and the correct output listed. The questions cover topics such as variable scope, operators, pointers, arrays, and multi-dimensional arrays.

Uploaded by

vasanthi2014
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views5 pages

Test Your C Skills Class: Roll No: 1. What Will Be Output of Following C Code?

The document tests C programming skills through a series of code snippets and their expected outputs. It contains 10 multiple choice questions, each with a short code sample and the correct output listed. The questions cover topics such as variable scope, operators, pointers, arrays, and multi-dimensional arrays.

Uploaded by

vasanthi2014
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Test Your C Skills

Class: Roll No:

1. What will be output of following c code?


extern int a;
void main()
{
int a=5;
{
int a=10;
printf("%d",a++);
}
printf(" %d",a);
getch();
}
int a=20;

Output:
10 5

2. What will be output of following c code?


void main()
{
int i;
for(i=0;i<=5;i++);
printf("%d",i);
getch();
}

Output:
6

3. What will be output of following c code?

main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}

Output:

00131

1
4. What will be output of following c code?

main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}

Output:

12

5. What will be output of following c code?


main( )
{
static int a[ ] = {0,1,2,3,4};
int *p[ ] = {a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf(\n %d %d %d, ptr-p, *ptr-a, **ptr);
*ptr++;
printf(\n %d %d %d, ptr-p, *ptr-a, **ptr);
*++ptr;
printf(\n %d %d %d, ptr-p, *ptr-a, **ptr);
++*ptr;
printf(\n %d %d %d, ptr-p, *ptr-a, **ptr);
}

Output:

111
222
333
344

6. What will be output of following c code?

#include<stdio.h>

2
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}

Output:

77

7. What will be output of following c code?

#include<stdio.h>
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}

Output:

SomeGarbageValue---1

8. What will be output of following c code?

main()
{
static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
int i;
char *t;

3
t=names[3];
names[3]=names[4];
names[4]=t;
for (i=0;i<=4;i++)
printf("%s",names[i]);
}

Output:

Compiler error: Lvalue required in function main

9. What will be output of following c code?

#include<stdio.h>

main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}

Output:

10. What will be output of following c code?


main( )
{
int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf(%u %u %u %d \n,a,*a,**a,***a);
printf(%u %u %u %d \n,a+1,*a+1,**a+1,***a+1);
}

Output:
4
100, 100, 100, 2
114, 104, 102, 3

You might also like