0% found this document useful (0 votes)
42 views

C Question Paper1

The document contains 10 multiple choice questions that test knowledge of C programming concepts like pointers, arrays, structures, and functions. It also contains 5 code snippets with output prediction questions that cover topics like extern variables, character arrays, nested structures, goto statements, and dynamic memory allocation. The total marks for the questions is 25.

Uploaded by

Ashwin K Shetty
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

C Question Paper1

The document contains 10 multiple choice questions that test knowledge of C programming concepts like pointers, arrays, structures, and functions. It also contains 5 code snippets with output prediction questions that cover topics like extern variables, character arrays, nested structures, goto statements, and dynamic memory allocation. The total marks for the questions is 25.

Uploaded by

Ashwin K Shetty
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

C

TOTAL MARKS: 25

predict the output of the following:


1. void main()
{
int const * p=5;
printf("%d",++(*p));
}
a> 5
b> Compiler Error
c> 6
d> 7

2. main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
a> 12345
b> 54321
c> Compiler Error
d> None of the above

3. main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
Page 1 of 6

for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}
a> 2233446557
b> 2222223465
c> 28344675
d> None of the above
4. main()
{
int c=- -2;
printf("c=%d",c);

a> -2
b> 2
c> Syntax Error
d> None of the above

5. main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
a> 2 2
b> 1 2
c> 2 1
d> None of the above

6. main()
{
Page 2 of 6

int i=10;
i=!i>14;
Printf ("i=%d",i);
}

a> i = 0
b> i = 14
c> Syntax Error
d> None of the above

7. #include
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}
a> Compiler Error
b> Syntax Error
c> 3 hello
d> None of the above

8. main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}

a> 55455
b> 45545
Page 3 of 6

c> 45455
d> None of the above

9. #include
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);
}

a> Some garbage value----1


b> 2----2
c> 1----Some garbage value
d> None of the above

10.

main()

{
char *p;
p="Hello";
printf("%c\n",*&*p);
}

a> Hello
b> H
c> Some garbage value
d> None of the above

Predict the output and give reasons:

Marks: 15

1. main()
{
extern int i;
Page 4 of 6

i=20;
printf("%d",i);
}

2. #include
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);
}

3. #include
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}

4. main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
Page 5 of 6

if (i>2)
goto here;
i++;
}
}
fun()
{
here:
printf("PP");
}

5. #include
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}

Page 6 of 6

You might also like