0% found this document useful (0 votes)
23 views9 pages

Cpaper 1

The document presents a series of programming questions and code snippets, primarily in C, that require predicting the output or identifying errors. Each question explores different aspects of C programming, including variable types, control structures, memory management, and preprocessor directives. The content is structured as a quiz for individuals seeking to test their knowledge and understanding of C programming concepts.

Uploaded by

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

Cpaper 1

The document presents a series of programming questions and code snippets, primarily in C, that require predicting the output or identifying errors. Each question explores different aspects of C programming, including variable types, control structures, memory management, and preprocessor directives. The content is structured as a quiz for individuals seeking to test their knowledge and understanding of C programming concepts.

Uploaded by

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

JobSeeker SOLUTIONS

SET-A
Note:-
The program output may depend on the information based on this assumptions (for
example sizeof(int) == 2 may be assumed).

Predict the output or error(s) for the following:


Q1. void main()
{
int const * p=5;
printf("%d",++(*p));
}

Q2. main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}

Q3. main()

{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}

Q4. main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}

Jobseersolution.wordpress.com Page 1
Q5). 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; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}

Q6). main()
{
extern int i;
i=20;
printf("%d",i);
}

Q7). 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);
}

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

Q9). main()
{
int i=3;
switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}

Jobseersolution.wordpress.com Page 2
Q10). main()
{
printf("%x",-1<<4);
}

Q11). main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
}

Q12). main()
{
int c=- -2;
printf("c=%d",c);
}

Q13). #define int char


main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}

Q14). main()
{
int i=10;
i=!i>14;
printf("i=%d",i);
}

Q15). #include<stdio.h>
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;

Jobseersolution.wordpress.com Page 3
printf("%d",++*p + ++*str1-32);
}

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

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

Q18) #include<stdio.h>
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}

Q19). main()
{
printf("\nab");
printf("\bsi");
printf("\rha");

Jobseersolution.wordpress.com Page 4
}

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

Q21). #define square(x) x*x


main()
{
int i;
i = 64/square(4);
printf("%d",i);
}

Q22). main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='\0') ++*p++;
printf("%s %s",p,p1);
}

Q23). #include <stdio.h>


#define a 10
main()
{
#define a 50
printf("%d",a);
}

Q24) #define clrscr() 100


main()
{
clrscr();
printf("%d\n",clrscr());
}

Q25). main()
{
printf("%p",main);
}

Jobseersolution.wordpress.com Page 5
Q26) main()
{
clrscr();
}
clrscr();

Q27) enum colors {BLACK,BLUE,GREEN}


main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
}

Q28) void main()


{
char far *farther,*farthest;
printf("%d..%d",sizeof(farther),sizeof(farthest));
}

Q29) main()
{
int i=400,j=300;
printf("%d..%d");
}

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

Q31) main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
if (i>2)
goto here;
i++;
}
}
fun()

Jobseersolution.wordpress.com Page 6
{
here:
printf("PP");
}

Q32) main()
{
static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
int i;
char *t;
t=names[3];
names[3]=names[4];
names[4]=t;
for (i=0;i<=4;i++)
printf("%s",names[i]);
}

Q33) void main()


{
int i=5;
printf("%d",i++ + ++i);
}

Q34) void main()


{
int i=5;
printf("%d",i+++++i);
}

Q35) #include<stdio.h>
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;

case j: printf("BAD");
break;
}
}

Jobseersolution.wordpress.com Page 7
Q36) main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}

Q37) #define f(g,g2) g##g2


main()
{
int var12=100;
printf("%d",f(var,12));
}

Q38) main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
}

Q39) #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);
}

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

Jobseersolution.wordpress.com Page 8
Q41) #include<stdio.h>
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}

Q42) main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}

Q43) main()
{
printf("%d", out);
}
int out=100;

Q44) main()
{
extern out;
printf("%d", out);
}
int out=100;

Jobseersolution.wordpress.com Page 9

You might also like