C Contest Probable Questions
C Contest Probable Questions
Ujire-574240
Department of Information Science & Engineering
C-Contest (Probable questions)
Prepared by: Prof. Prasad B S, Asst Prof, Dept of ISE
Note: Suitable header files can be assumed to be included wherever necessary and missing header files cannot be reason for any answer.
1) main(){
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);}
5)
What is the output of this program ?
Union tag
{
int a;
char x,y;
}name;
(Assume storage is Little Endian technique)
int main() {
name.a=258;
printf(\n x=%d y=%d,name.x,name.y); }
a)00 00 ac 40 b)00 ff ff 05 c)compiler error d)run time error saying illegal pointer conversion
----------------------------------------------------------------------------------------------------------------
16)# include<stdio.h>
aaa() {
printf("hi");
}
bbb(){
printf("hello");
}
ccc(){
printf("bye");
}
main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[2]();
}
a)hihellobyebye b)hihellobye c)bye d)aaabbbcccbye
----------------------------------------------------------------------------------------------------------------
17)#include<stdio.h>
{
int s=0;
while(s++<10) {
if(s<4 && s<9)
continue;
printf("\n%d\t",s);
}}
1) 1 2 3 4 5 6 7 8 9 2) 1 2 3 10 3) 4 5 6 7 8 9 10 4) 4 5 6 7 8 9
----------------------------------------------------------------------------------------------------------------
18)struct point
{
int x;
int y;
};
struct point origin,*pp;
main()
{
pp=&origin;
printf("origin is(%d%d)\n",(*pp).x,pp->y);
}
a) 1 b) Compilation error c) 2 d) 3
----------------------------------------------------------------------------------------------------------------
22) #define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
}
a) 10 b) 20 c) 1020 d) 12
----------------------------------------------------------------------------------------------------------------
24)main() {
int i=0;
if(i++)
main();
{
printf(f);
exit(0);}
main();
}
----------------------------------------------------------------------------------------------------------------
36)main() {
unsigned int i=65000;
while(i++!=0);
printf("%d",i); }
----------------------------------------------------------------------------------------------------------------
49)int i=10;
main() {
extern int i; {
int i=20; {
const volatile unsigned i=30;
printf("%d",i); }
printf("%d",i); }
printf("%d",i); }
----------------------------------------------------------------------------------------------------------------