Você está na página 1de 7

ANKURA- 2011 NISB-IEEE

EXTREME_CODING
Time Limit:45 mins
 Choose the correct answer from the options given (N.O.T abbreviation have been used for “none
of these”) . If no options are given, then you need to write the output assuming appropriate header
files have been included, or mention if the answer is an ERROR.
 Each question carry equal marks. In case of a tie between two participants, the one who has
answered more no of star marked questions will be preferred.

(1) void main(){


int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d %d\n",y,x<<2,x>>2); }
(a)92 220 14 (b) 94 228 14 (c)94 228 57 (d) compiler error (e) N.O.T

(2) #define swap(a,b) a=a+b;b=a-b;a=a-b;


void swap1(int,int);
void main()
{ int x=8,y=10;
swap(x,y);
printf(“%d %d”,x,y);
swap1(x,y);
printf(“%d %d”,x,y);}
void swap1(int a,int b)
{ int t;
t=a; b=a; a=t;
return; }
(a) 10 8 10 10 (b) 10 8 8 10 (c) 10 8 10 8 (d) 8 10 8 10

(3) main() {
static i=3;
printf("%d",i--);
return i>0 ? main():0; }

(4) void main() {


char *s[]={ "dharma","hewlett-packard","siemens","ibm"};
char **p;
p=s;
printf("%s",++*p);
printf("%s",*p++);
printf("%s",++*p); }
(5 ) #include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)
int main()
{ printf("%s\n",h(f(1,2)));
printf("%s\n",g(f(1,2)));
return 0; }

(6) #include <stdio.h>


int main() {
int i = 6;
if( ((++i < 7) && ( i++/6)) || (++i <= 9));
printf("%d\n",i);
return 0; }

*(7) void main()


{ enum tag{agra,patna=2,cochin,goa=patna,shimla};
enum tag city;
printf("cco%chin% ""dulkar"+shimla,"patna"[patna],
cochin+shimla+sizeof(city));
}

*(8) void main()


{ char *s1="NISB-IEEE";
char *s2="NISB-IEEE";
if(s1==s2)
printf("ADROIT");
else
printf("ANKURA"); }

(9) void main()


{ int a=-24;
a=a>>4;
printf("%d ",a); }

(10) void main()


{ unsigned int x=-1;
printf("%d\n",x);
printf("%u",x*-1); }
(11) void main()
{ int c=0,d=5,e=10,a;
a=c>1?d>1||e>1?300:200:100;
printf("%d",a); }
(a) 100 (b) 200 (c) 300 (d) compile error

*(12) void main()


{ int x=20,y=10,z;
z=x+++y;
y=z--- -x;
printf("%d %d %d",x,y,z); }

(13)There are code fragment of two programs. Assume code block is same for both fragment. Compare
efficiency of both fragment
Fragment 1:
For(i=0;i<100;i++)
For(j=0;j<10;j++)
{ code block }
Fragment 2:
For(i=0;i<10;i++)
For(j=0;j<100;j++)
{code block }
(a) equally efficient (b) fragment 1 is more efficient
(c) none of these (d) fragment 2 is more efficient

(14) void main()


{
printf("%d %d",sizeof("ANKURA"),strlen("ANKURA"));
}
(a) 7 6 (b) 7 7 (c) 6 7 (d) 6 6 (e) N.O.T

(15)void main()
{ unsigned i=1;
signed j=-1;
if(i<j) printf("less");
else if(i>j) printf("greater");
else if(i==j) printf("equal"); }

(16)void main()
{ int i;
i=~!!~printf(““);
printf(“%d”,i);}

(17) int main()


{ int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i=++a[1];
j = a[1]++;
m=a[i++];
printf("%d, %d, %d", i, j, m);
return 0; }
(a)1,2,5 (b) 2,3,20 (c) 3,2,15 (d)2,1,15

(18) int main()


{ struct s1 { char *z; int i; struct s1 *p; };
static struct s1 a[] = {{"Nagpur", 1, a+1} , {"Chennai", 2, a+2} , {"Bangalore", 3, a} };
struct s1 *ptr = a;
printf("%s,", ++(ptr->z));
printf(" %s,", a[(++ptr)->i].z);
printf(" %s", a[--(ptr->p->i)].z);

return 0; }

(19)int main()
{ int x = 10, y = 20;
if(!(!x) && x)
printf("x = %d\n", x);
else
printf("y = %d\n", y);
return 0; }
(a) X=10 (b) x=0 (c) y=20 (d) x=1

(20)int main()
{ static char *s[] = {"black", "white", "pink", "violet"};
char **ptr[] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
++p;
printf("%s", **p+1);
return 0; }
(a) Ink (b)ite (c) let (d) ack

(21) int main()


{ union a { int i; char ch[2]; };
union a u;
u.i= 540;
printf("%d, %d \n", u.ch[0], u.ch[1]);
return 0; }

(22) int main() {


static char mess[6][30] = {"Don't walk in front off me...",
"I may not follow;",
"Don't walk behind me...",
"Just walk beside me...",
"And be my friend." };
printf("%c, %c\n", *(mess[2]+7), *(*(mess+2)+9));
return 0; }

(23) int fun(int);


int main()
{ float k=3;
fun(k=fun(fun(k)));
printf("%f\n", k);
return 0; }
int fun(int i) {
i++; return i; }

(24) int main()


{ int x, y, z;
x=y=z=1;
z = ++x || ++y && ++z;
printf("x=%d, y=%d, z=%d\n", x, y, z);
return 0; }

(25)Which of the following structure declaration style is better for efficient


storage?
Struct struct1 struct struct2 struct struct3
{ { {
Char ch1; Char ch1; int x;
int x; Char ch2; Char ch1;
Char ch2; int x; Char ch2;
} ; }; };
(a) Struct1 (b) struct2 (c) struct3
(d) All are equally good (e) struct2 and struct 3 both

(26) Assuming LINUX/UNIX platform write how many times printf function Will
get executed .
int main()
{ printf("S1\n");
if(fork()) printf("S2\n");
else
fork(); printf("s3\n");
printf("S4\n");
return 0; }
(a) 4 (b) 6 (c ) 7 (d) 8 (e) 10

(27) int main()


{ int i=2, j=3;
Printf(“%d”,i=j+i,j=i+j);
return(0); }
(a) 7 (b)5 (c) 8 (d) garbage (e) compiler
error

(28) int main() {


enum x{ ab,bc=10,de};
ab=(bc++) +de;
printf("%d %d %d",ab,bc,de); }

(29) void convention(int,int,int);


void main(){
int a=5;
convention(a,++a,a++); }
void convention(int p,int q,int r){
printf("%d %d %d",p,q,r); }
(a)5,6,6 (b)7,7,5 (c)5,5,5 (d)5,6,7

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

Você também pode gostar