Professional Documents
Culture Documents
Q 1. main() {
char ch='A';
while(ch<='F'){
switch(ch){
case'A':case'B':case'C':case'D':ch++;continue;
case'E':case'F':ch++;
}
putchar(ch);
}}
Q 4. main() {
int c=- -2; printf(“%d”, c);
}
Q 6. 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);
}
Q 9. main( ) {
void *vp;
char ch = ‘g’, *cp = “goofy”;
int j = 20;
vp = &ch; printf(“%c”, *(char *)vp);
vp = &j; printf(“%d”,*(int *)vp);
vp = cp; printf(“%s”,(char *)vp + 3);
The GCC compiler has been used to test/execute the code, unless stated otherwise.
Page 1
CAMPUS PLACEMENT COMMITTEE
MCA BATCH OF 2012
MOCK TEST
}
Q 10. main() {
char *cptr,c;
void *vptr,v;
c=65; v=0; cptr=&c; vptr=&v;
printf("%c%d",c,v);
}
Q 11. main() {
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof str2,sizeof("abcd"));
}
Q 14. main() {
char str1[] = {'s','o','m','e'};
char str2[] = {'s','o','m','e','\0'};
if(strcmp(str1,str2)) printf("Strings are not equal\n");
else printf(“Equal”);
}
The GCC compiler has been used to test/execute the code, unless stated otherwise.
Page 2