You are on page 1of 2

C Aptitude 12 (i think)

int main() {
unsigned int i=-1;
printf("%d\n",i);
printf("%u\n",i*-1);
}

1.
int main() {
int a=49;
printf(&a);
8.
}
/*Hint: What will be the output in multimedia lab int main() {
int i=0;
and in impact lab? */
i=5,
printf("%d\n", i),
2.
//commas are intentional
#define EQUAL =
printf("Hello\n");
int main() {
}
int i EQUAL 5;
if(i EQUALEQUAL 5)
printf("Hello\n");
else
printf("World\n");

9.
int main() {
int i=5;
i==5?
{printf("Hello");}:
{printf(" world")};

}
3.
int main() {
int i=306;
printf("%c\n", i);
}
4.
int main() {
char *str[]={"abcd", "efgh", "ijkl"};
char **ptr=str;
printf("%d %d %d\n", sizeof(str),
sizeof(*str), sizeof(ptr));
printf("%s %s\n", str[0], ++(*ptr++));
printf("%s\n", *ptr);
}

}
10.
int main() {
double d=010e5;
printf("%ld\n",(int)d);
}
11.
int main() {
int *p=calloc(5, sizeof(int));
p=realloc(p, 10*sizeof(int));
printf("%d\n", sizeof(p));
}

5.
int main(int x) {
printf(%d,x) ;
}

12.
int main() {
char *ptr;
printf(%c%s,ptr[1],
ptr=&malfunction[4]);
}

6.
int main() {
int a[2][2]={{2},{3}};
printf(%d,a[0][0]);
printf(%d,a[0][1]);
printf(%d,a[1][0]);
printf(%d,a[1][1]);
}

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

7.

14.
#define PRINT(int) printf("int=%d",int);

int main() {
int x,y,z;
x=03;y=-1;z=01;
PRINT(x^x);
z<<=3;PRINT(x);
y>>=3;PRINT(y);
}

19.
int main() {
int a=10,b=20;
a>=5?b=100:b=200;
printf("%d\n",b);
}

15.
20.
//Assume sizeof(int)=4 and sizeof(char)=1
int main() {
int main() {
struct emp{
int a[] ={ 1,2,3,4,5,6,7};
char emp[];
char c[] = {' a','x','h','o','k'};
int empno;
printf("%d\t %d ", (&a[3]-&a[0]),(&c[3]float sal;
&c[0]));
};
}
struct emp member = { "TIGER"};
printf(" %d %f", member.empno,
16.
member.sal);
int main()
}
{
struct s1 {int i; };
struct s2 {int i; };
struct s1 st1;
struct s2 *p, st2;
st1.i =5;
st2=st1;
p = &st1;
printf("%d\n" , p->i);
}
17.
#define prn(a) printf("%d",a)
#define print(a,b,c) prn(a), prn(b), prn(c)
#define max(a,b) (a<b)? b:a
int main() {
int x=1, y=2;
print(max(x++,y),x,y);
print(max(x++,y),x,y);
}
18.
char *f(){
char *s=malloc(8);
strcpy(s,"goodbye");
}
int main() {
char *f();
printf("%c",*f()='A');
}

You might also like