Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
main()
{
int x;
x = 4 % 5 + 6 % 5;
printf("x = %d",x);
}
--------------3.
main()
{
int i;
float j;
i =5/2;
j =5/2;
printf("%f %d ",j,i);
}
-------------4.
main()
{
float a =12.25,b =13.25;
if(a = b)
printf("RISC");
else
printf("CISC");
}
------------5.
main()
{
int x =100;
if(!!x)
printf("x =%d",!x);
else
printf("x =%d",x);
}
------------6.
main()
{
long i=65536 +65;
printf("%c\n",i);
char a;
printf("%d",a);
}
--------------7.
main()
{
long i=65536 +65;
printf("%c\n",i);
Page 1
C
char a;
printf("%d",a);
}
---------8.
main()
{
int q =2,d=3,st;
st = q*d/4-12/12+12/3*16/d;
printf("st =%d",st);
}
---------9.
main()
{
int q =2,d=3,st;
st = q*d/4-12/12+12/3*16/d;
printf("st =%d",st);
}
--------10.
main()
{
printf("%d %f\n",4,4);
printf("%d %f\n",4.0,4.0);
}
-------11.
#define MEAN(a,b,c,d,e) (a+b+c+d+e)/5
main()
{
int a,b,c,d,e,m;
a=1;b=2;c=3;d=4;e=5;
m = MEAN(a,b,c,d,e);
printf("Mean of the five numbers is =%d",m);
}
-------------12.
main()
{
printf("%d",1&2);
}
-------------13.
main()
{
int x;
x =3 * 4 % 5;
printf("x = %d",x);
}
-------------14.
main()
{
printf("%d %d %d %d ",72,072,0x72,0X72);
}
-------------15.
main()
{
printf("%d", 4||2);
}
-------------Page 2
C
16.
main()
{
printf("%d",3||2);
}
------------17.
main()
{
printf("%d",3&&2);
}
-------------19.
main()
{
int g = 300 * 300 /3;
printf("g =%d",g);
}
-------------20.
main()
{
int g = 300 * 300 /3;
printf("g =%d",g);
}
-------------21.
main()
{
printf("%d",3>2);
}
-------------22.
main()
{
float x = 5.5,y=8.0;
x*= ++x;/*for float there is no effect in using post ++*/
y++;
printf("%f %f",x,y);
}
----------------23.
main()
{
int x=2,y,z,s;
x*= y=z=4;
s=(y==z);
printf("%d\n",x);
printf("%d",s);
}
---------------24.
main()
{
int x,y,z;
x=2;y=1;z=0;
x=(x&&y)||z;
printf("%d\n",x);
printf("%d\n",x||y&&z);
x=y=1;
z=x++ -1;
printf("%d\n",x);
printf("%d\n",z);
Page 3
C
{
int y=100,x;
x = y= y++;
printf("%d %d ", x,y);
}
---------------32.
#include<stdio.h>
main()
{
int x,y=1,z;
if (z=(y==1)) x=5;
else x=10;
printf("x=%d\t y = %d\t z=%d ",x,y,z);
}
---------------33.
# include<stdio.h>
main()
{
int x,y=1,z;
if (z=y<0) x=3;
else
if (y==0) x=5;
else x=7;
printf ("%d %d %d",x,y,z);
}
-----------------34.
#include<stdio.h>
int i=0;
main()
{
auto int i=1;
printf("%d\n",i);
{
int i=2;
printf("%d\n",i);
{
i+=1;
printf("%d\n",i);
}
printf("%d\n",i);
}
printf("%d\n",i);
}
------------------35.
# include<stdio.h>
main()
{
int a=6;
a+= a++ + ++a;
printf("%d",a);}
-----------------36.
main()
{
static char food[]="yummy";
char *ptr;
ptr=food + strlen(food);
while (--ptr>=food)
puts(ptr);
Page 5
C
}
-------------------37.
# include>-------------------
-------------------
#includ <stdio.h>
main()
{
in i;
=0x10+010+10;
printf("%d",i);
}
---------------main()
{
in x;
5;
printf(" %d",x);
--------------main()
{
in i;
floa j;
=5/2;
=5/2;
printf("% % ",j,i);
}
-------------main()
{
floa =12.25, =13.25;
if( b)
printf("RISC");
else
printf("CISC");
}
------------main()
{
in =100;
if(!!x)
printf(" =%d",!x);
else
printf(" =%d",x);
}
-------------
Page 6
main()
{
lon i=6553 +65;
printf("%c\n",i);
cha a;
printf("%d",a);
}
--------------
main()
{
lon i=6553 +65;
printf("%c\n",i);
cha a;
printf("%d",a);
}
---------main()
{
in =2,d=3,st;
s q*d/-12/12+12/3*16/d;
printf("s =%d",st);
}
--------- main()
{
in =2,d=3,st;
s q*d/-12/12+12/3*16/d;
printf("s =%d",st);
}
-------- main()
{
printf("% %f\n",4,4);
printf("% %f\n",4.0,4.0);
}
-------#defin MEAN(a,b,c,d,e (a+b+c+d+e)/5
main()
{
in a,b,c,d,e,m;
a=1;b=2;c=3;d=4;e=5;
MEAN(a,b,c,d,e);
printf("Mea o th fiv number i =%d",m);
}
-------------main()
{
printf("%d",1&2);
}
-------------main()
{
in x;
= 5;
printf(" %d",x);
}
-------------Page 7
C
main()
{
printf("% % % % ",72,072,0x72,0X72);
}
-------------main()
{
printf("%d" 4||2);
------------- main()
{
printf("%d",3||2);
------------main()
{
printf("%d",3&&2);
}
-------------main()
{
in 30 30 /3;
printf(" =%d",g);
}
-------------main()
{
in 30 30 /3;
printf(" =%d",g);
}
-------------main()
{
printf("%d",3>2);
-------------main()
{
floa 5.5,y=8.0;
x* ++x;/*fo floa ther i n effec i usin pos ++*/
y++;
printf("% %f",x,y);
----------------main()
{
in x=2,y,z,s;
x* y=z=4;
s=(y==z);
printf("%d\n",x);
printf("%d",s);
}
---------------main()
{
in x,y,z;
x=2;y=1;z=0;
x=(x&&y)||z;
Page 8
C
printf("%d\n",x);
printf("%d\n",x||y&&z);
x=y=1;
z=x+ -1;
printf("%d\n",x);
printf("%d\n",z);
z+ x+ ++y;
printf("%d\n%d\n",x,z);
}
----------------main()
{
in 0,z,y;
!x|x;
x|!x;
printf("% %d",z,y);
}
-------------#includ <stdio.h>
main()
{
in i=100,j=200;
printf("% %d");
}
--------------main()
{
in 2,z;
for(x=2;x<=10;x++)
{
printf("%d\t",x);
printf("%d\n",~x);
}
x=2;
~(x|x);
printf("%d",z);
}
----------------main()
{
in x=1,y=1,z=1,aa;
x+=y+=z;
printf("% %
%d\n",x,y,z);
a x<y?x++:y++;
printf("%d",aa);
}
---------------main()
{
in x-1,y-1,z-1,a;
}
--------------- main()
{
in y=100,x;
y y++;
}
---------------main()
{
in y=100,x;
y y++;
printf("% %
}
----------------
" x,y);
#include<stdio.h>
main()
{
in x,y=1,z;
i (z=(y==1) x=5;
els x=10;
printf("x=%d\ %d\ z=% ",x,y,z);
}
--------------- include<stdio.h>
main()
{
in x,y=1,z;
i (z=y<0 x=3;
else
i (y==0 x=5;
els x=7;
}
-----------------
#include<stdio.h>
in i=0;
main()
aut in i=1;
printf("%d\n",i);
in i=2;
printf("%d\n",i);
i+=1;
printf("%d\n",i);
printf("%d\n",i);
printf("%d\n",i);
}
------------------ include<stdio.h>
main()
{
in a=6;
a+ a+ ++a;
printf("%d",a);}
-----------------main()
{
cha *ptr;
ptr=foo strlen(food);
Page 10
whil --ptr>=food)
puts(ptr);
}
------------------- include<stdio.h>
main()
{
cha *ptr;
ptr=foo strlen(food);
whil --ptr>=food)
puts(ptr);
}
------------------main()
{
in =10;
#include<stdio.h>
printf("%d",i);
}
------------------ defin FUN(k a+b/*-bc*/c
main()
{
in a,b,c,*d,bc;
a=6;b=5;c=4;bc=2;
d=&c;
printf("%d\n",FUN(K));
}
------------------main()
{
in x,a,b,c;
a=10;b=5;c=5;
x=a== c++;
printf("%d",x);
}
------------------include<stdio.h>
main()
{
in *a=71;
printf("% %d",a,*a);
}
------------------- include<stdio.h>
main()
{
stati in arr[]= 9 ,9 ,9 ,10 ,10 ,10 ,10 ,10 };
in *pt arr+1;
print(++ptr,pt--,ptr,ptr++,++ptr);
}
print(in *a,in *b,in *c,in *d,in *e)
{
printf("\n% % % % %d",*a,*b,*c,*d,*e);
}
--------------------
Page 11
C
#includ <stdio.h>
main()
{
in i;
in a[ {1,2,3,4,5,6,7};
for(i=0;i<=4;i++)
{
printf( % ",a[i]);
}
}
----------------main()
{
in a,i;
11;
i+ ++ --i;
printf("% %d",a,i);
}
----------------------main()
{
in i=10;
printf("\ valu o =% addres o =%u",i,&i);
&i==7200;
printf("\nne valu o i=% ne addres o =%u",i,&i);
}
-----------------------main()
{
in *i,*j,**k;
j=i+2;
=&i;
printf("\nk=% j=% i=%u",*k,j,i);
}
-------------------main()
{
in i=10;
printf("\ valu o =% addres o =%u",i,&i);
&i==7200;
printf("\nne valu o i=% ne addres o =%u",i,&i);
}
-------------------main()
{
in *i,*j,**k;
j=i+2;
=&i;
printf("\nk=% j=% i=%u",*k,j,i);
}
---------------------#includ <stdio.h>
main()
{
union{
struc cathy{
in cathy;
cha joe;
Page 12
C
}cat;
in m;
}ass;
printf("\nsiz o :% ,sizeof(ass));
}
----------------#include<stdio.h>
main()
{
in i=3,j;
j i+ ++ ++i;
printf("% %d",j,i);
}
--------------main()
{
in aa0aa1aa2aa3aa4aa5aa6aa7aa8aa9aazz1zz =10;
printf("%d",aa0aa1aa2aa3aa4aa5aa6aa7aa8aa9aa);
}
----------------#include<stdio.h>
main()
{
cha in;
whil ((i getchar())! '*')
{
i ((i > 'a' & (i <='z'))
another();
}
}
another()
{
stati in i=0;
i++;
printf("%d",i);
}
--------------#include<stdio.h>
main()
{
in stud[5][2]={
{1234,56},
{1212,33},
{1434,80},
{1312,78},
{1203,75}
};
in i,j;
for(i=0;i<=4;i++)
{
printf("\n");
for(j=0;j<=1;j++)
printf("%d",*(*(stud+i)+j));
}
}
--------------Page 13
C
includ <stdio.h>
defin BYTESIZE
main()
{
in printbits(int);
in =5;
printbits(~x);
}
printbits(x)
in x;
{
in i;
for(i=0;i<BYTESIZE*sizeof(x);++i)
printf("%d",(va <<i&1<<BYTESIZE*sizeof(int-1)?1:0);
putchar('\n');
}
-----------------#includ <stdio.h>
main()
{
in i=12,j=3, =2;
/
1+ 0+ fo XO
/
prec = compl ,AND,OR,XO
printf("% ",i^j&~k);
printf("% %d", j, & k);
}
------------main()
{
/
----------------#include<stdio.h>
main()
{
in =1, =1,c=1,x;
a+ b+=c;
?a++:b++;
printf("%d\n",x);
printf("%d\n", a< a++:b++);
printf("%d\ %d\n",b,c);
}
----------------------#include<stdio.h>
main()
{
in a,b,c;
=c -1;
++ | ++ & ++ ;
Page 14
*/
*/
*/
C
printf(" % , % %d",a,b,c);
}
------------#include<stdio.h>
main()
{
in a,b,c;
=c -1;
++ | ++ & ++ ;
printf(" % , % %d",a,b,c);
}
------------#include<stdio.h>
main()
{
in a,b,c;
-2;
++ & ++ ;
printf(" % , % %d",a,b,c);
}
-------------main()
{
in x,y=100;
y y++;
printf(" %d, % ",x,y);
}
--------------#include<stdio.h>
main()
{
in x,y,z;
0;
while( <10)
{
+ ++y;
printf("%
%d\n",x,y);
}
}
-------------main()
in x=1,y=1;
i (y<0)
i (y>0 x=3;
els x=5;
printf("%d",x);
}
--------------#include<stdio.h>
main()
{
in c,n =0,n =0;
while(( =getchar())! EOF)
switch(c {
Page 15
cas
cas
cas
cas
cas
cas
cas
cas
cas
cas
'0
'1
'2
'3
'4
'5
'6
'7
'8
'9
:
:
:
:
:
:
:
:
:
:
nd++;
default:
no++;
break;
}
printf("% % ",nd,no);
}
------------------main()
{
in x=1,y=1;
i (y<0)
i (y>0 x=3;
els x=5;
printf("%d",x);
}
----------------main()
{
in x,y=1,z;
i (x=y=z);x=3;
printf("% %d",x,z);
}
---------------main()
{
in a,b;
- - -3;
- - --3);
printf(" % =%d",a,b);
}
---------------#include<stdio.h>
main()
{
lon count;
coun 62000+1536+10;
printf("%l ",count);
}
---------------#include<stdio.h>
main()
{
lon count;
coun 62000+1536+10;
printf("%l ",count);
Page 16
C
}
--------------main()
{
lon i;
=65536+300;
printf("%l ",i);
}
--------------main()
{
in *a;
* 1;
printf("% %d",a,*a);
}
----------------#includ <stdio.h>
in a[][2 ={1,2,3,4};
main()
{
in i,j;
in (*p)[2]=a;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
p++;
}
}
--------------main()
{
in *a=1;
printf("% %d",a,*a);
}
--------------main()
{
cha a[]={"jeban"};
printf("%*s",(40+strlen(a)),a);
}
---------#includ <stdio.h>
voi cube(in *,in *,in *);
main()
{
in x=5,y,z;
cube(&x,&y,&z);
printf("valu o =%d",x);
printf("\nIt cub =%d",z);
}
voi cube(in *a,in *b,in *c)
{
* (*a)*(*a);
* (*b)*(*a);
}
---------------main()
{
in i=2,j=3,k;
Page 17
k=i+++j;
printf("% % %d",i,j,k);
}
----------compute(in m,in n)
{
if(m==0)
return(n+1);
else
{
if(n==0)
compute(-1,1);
else
compute(m,compute(-1,n));
}
}
main()
{
in i;
compute(2,3);
printf("%d",i);
}
-----------------main()
{
in i=0;
cha *ca ="city\0ki0ng";
while(*cat++)
{
i++;
printf("%d\n",i);
-----------------#includ <stdio.h>
in i;
main()
{
cha joe[10 "city\0ki0ng";
cha ch;
for(i=0;(ch=joe[i]!=0);i++)
ch=ch+'a-'A';
printf("%d\n",ch);
}
}
-------------#includ <stdio.h>
in i;
main()
{
Page 18
C
cha joe[10 "city\0ki0ng";
cha ch;
for(i=0;(ch=joe[i]!=0);i++)
ch=ch+'a-'A';
printf("%d\n",ch);
}
}
-----------
#includ <stdio.h>
main()
{
FIL *fp;
cha str[20];
f fopen("new.out","w");
if(f = 0)
scanf("%s",str);
fprintf(fp,"%s",str);
fclose(fp);
}
}
---------------#includ <stdio.h>
main()
{
FIL *fp;
cha str[20];
f fopen("new.out","w");
if(f = 0)
scanf("%s",str);
fprintf(fp,"%s",str);
fclose(fp);
}
}
--------------#includ <stdio.h>
main()
{
FIL *fp;
cha a;
f fopen("old.out","w");
if(f = 0)
for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
fprintf(fp,"%c",a);
fclose(fp);
}
Page 19
C
}
------------------main()
{
in a=(10,15,12,77);
printf("% ",a);
}
----------------main()
{
cha a;
printf("%d",(2^3)+(a^a));
}
----------------main()
{
in 5;
printf("%d",i);
return(991211233232132323232242243333322232344233232323232342342242422);
printf("hai");
}
----------------main()
{
in i=4,*j,*k;
j=&i;
printf("\n%d\n",j);
j=j+1;
printf("\n%d\n",j);
j=j+9;
k=j+3;
printf("% % % ", , ,k);
}
-------------#include<stdio.h>
#include<conio.h>
#defin C printf("%c%c%c%c",27,91,50,74)
#defin MC(x,y printf("%c%c%d%c%d%c",27,91,x,59,y,72)
#defin V printf("%c%c%c%c",27,91,55,109)
#defin V printf("%c%c%c%c",27,91,53,109)
#defin V printf("%c%c%c%c",27,91,53,109)
main()
{
CL;
MC(12,33);
printf("hai");
VR /*macr fo revers vide o */
printf("\nhallo");
VO /*macr fo revers vide of */
printf("\nbye );
MC(17,25);
VB / macr fo vide blin */
printf("\nHELLO");
}
--------------Page 20
C
main()
{
printf("%d",0.3.);
}
---------------main()
{
in a=3,b=2;
i (a=b)
printf("Th tw number ar same");
else
printf("Th tw number ar no same");
}
--------------#includ <stdio.h>
main()
{
cha *s="abc";
cha *t;
fo (t=s;*t!='\0';++t)
switc (*t)
cas 'a':
putchar('1');
cas 'b':
putchar('2');
cas 'c':
putchar('3');
break;
putchar('\n');
}
------------------#includ <stdio.h>
main()
{
struc word
{
cha *string;
in length;
};
struc wor dict[2];
struc wor * =dict;
-----------------------#includ <stdio.h>
cha *strchr(cha *s,cha c)
{
while(*s++! c);
retur s;
}
Page 21
C
main()
{
cha str[30];
gets(str);
puts(strchr(str,'a'));
}
---------------#includ <stdio.h>
voi main(void)
{
in i=5;
printf("\n%d",i);
change(i/2);
printf("\n%d",i);
i=change(i/2);
printf("\n%d",i);
}
in change(in i)
{
retur i<= ;
}
------------ #includ <stdio.h>
main()
{
printf("%d",func());
}
in func()
{
_AX=100;
}
-------
#includ <stdio.h>
cha *mycopy(str)
cha *str;
{
cha ptr[20];
strcpy(ptr,str);
return(ptr);
}
main()
{
cha name[20];
cha parm[20];
strcpy(name,"malini");
par =mycopy(name);
puts(parm);
}
Page 22
C
-------------- include<stdio.h>
include<ctype.h>
main()
{
cha a;
getchar();
i isupper(a)
printf("entere valu i upper");
else
printf("entere valu i lower");
}
-------------main()
{
in *a=1;
printf("% %d",a,*a);
}
----------------mai ()
{
in 10,b=5;
^=b^=a^=b;
printf("% % ",a,b);
}
---------------main()
{
in 10,b=5;
^=b^=a^=b;
printf("% % ",a,b);
}
----------------main()
{
floa a=0.131200;
printf("% ",a);
}
-----------------main()
{
floa a=0.131200;
printf("% ",a);
}
--------------#includ <stdio.h>
main()
{
in *i,j;
=&j;
=i 5;
printf("% %d",i,&j);
}
---------------------#includ <stdio.h>
#defin TABLE_SIZ 45
Page 23
C
#includ "table.h"
#defin 10
#unde x
#defin 12
main()
{
in j;
CL;
MC(12,32);
VO;
printf("th tabl siz i %d",TABLE_SIZE);
incr(j,1,20)
printf("\n i %d",j);
printf("\nTh i %d",x);
}
-------------main()
{
cha a[10],*pc;
in j;
p a;
p
=p sizeof(a);
j=p-a;
printf("%d",j);
}
---------------
Newsgroups: placement
Received: from MAILQUEUE by VAYU (Mercury 1.21); 30 Jul 99 08:45:17 IST+530
Resent-from:
"ARVIND RAMAN" <EC19604@rect.ernet.in>
Resent-to:
placement%nb@rect.ernet.in
Resent-date:
Fri, 30 Jul 1999 08:45:16 IST+530
Received: from MAILQUEUE by VAYU (Mercury 1.21); 29 Jul 99 17:53:34 IST+530
From:
"Dhanush" <EC19611@rect.ernet.in>
Organization: R.E.C., Tiruchirappalli, INDIA
To:
ec19604@rect.ernet.in
Date:
Thu, 29 Jul 1999 17:53:09 IST+530
Subject:
Solved C questions
Priority: normal
X-mailer: Pegasus Mail v3.21
C problems
no. of questions - 86
-------------------1.
2.
#include <stdio.h>
main()
{
int i;
i =0x10+010+10;
printf("%d",i);
}
ans : 34
---------------main()
{
Page 24
C
int x;
x = 4 % 5 + 6 % 5;
printf("x = %d",x);
}
ans : 5
--------------3.
main()
{
int i;
float j;
i =5/2;
j =5/2;
printf("%f %d ",j,i);
}
ans : 2.000, 2
-------------4.
main()
{
float a =12.25,b =13.25;
if(a = b)
printf("RISC");
else
printf("CISC");
}
ans : RISC
------------5.
main()
{
int x =100;
if(!!x)
printf("x =%d",!x);
else
printf("x =%d",x);
}
ans : 0
------------6.
main()
{
long i=65536 +65;
printf("%c\n",i);
char a;
printf("%d",a);
}
error.
--------------7.
main()
{
int q =2,d=3,st;
st = q*d/4-12/12+12/3*16/d;
printf("st =%d",st);
}
ans : 21
---------8.
main()
{
printf("%d %f\n",4,4);
printf("%d %f\n",4.0,4.0);
Page 25
C
}
ans : 4 garbage
0 0
-------9.
#define MEAN(a,b,c,d,e) (a+b+c+d+e)/5
main()
{
int a,b,c,d,e,m;
a=1;b=2;c=3;d=4;e=5;
m = MEAN(a,b,c,d,e);
printf("Mean of the five numbers is =%d",m);
}
ans : 3
-------------10.
main()
{
printf("%d",1&2);
}
ans : 0
-------------11.
main()
{
int x;
x =3 * 4 % 5;
printf("x = %d",x);
}
ans : 12
-------------12.
main()
{
printf("%d %d %d %d ",72,072,0x72,0X72);
}
ans : 72 58 114 114
-------------13.
main()
{
printf("%d", 4||2);
}
ans : 1
-------------14.
main()
{
printf("%d",3||2);
}
ans : 1
------------15.
main()
{
printf("%d",3&&2);
}
ans : 1
-------------16.
main()
{
int g = 300 * 300 /3;
printf("g =%d",g);
}
Page 26
C
ans : 8154
-------------17.
main()
{
printf("%d",3>2);
}
ans : 1
-------------18.
main()
{
float x = 5.5,y=8.0;
x*= ++x;/*for float there is no effect in using post ++*/
y++;
printf("%f %f",x,y);
}
ans 15.75 9
----------------19.
main()
{
int x=2,y,z,s;
x*= y=z=4;
s=(y==z);
printf("%d\n",x);
printf("%d",s);
}
ans : 8
1
---------------20.
main()
{
int x,y,z;
x=2;y=1;z=0;
x=(x&&y)||z;
printf("%d\n",x);
printf("%d\n",x||y&&z);
x=y=1;
z=x++ -1;
printf("%d\n",x);
printf("%d\n",z);
z+= x++ + ++y;
printf("%d\n%d\n",x,z);
}
ans : 1
1
2
0
3
4
----------------21.
main()
{
int x = 0,z,y;
z = !x|x;
y = x|!x;
printf("%d %d",z,y);
}
ans : 1 1
-------------Page 27
C
22.
#include <stdio.h>
main()
{
int i=100,j=200;
printf("%d %d");
}
ans : 100 200
--------------23.
main()
{
int x = 2,z;
for(x=2;x<=10;x++)
{
printf("%d\t",x);
printf("%d\n",~x);
}
x=2;
z = ~(x|x);
printf("%d",z);
}
ans : 2 -3
3 -4
...
10 -11
-3
----------------24.
main()
{
int x=1,y=1,z=1,aa;
x+=y+=z;
printf("%d %d
%d\n",x,y,z);
aa = x<y?x++:y++;
printf("%d",aa);
}
ans : 3,2,1,2
---------------25.
main()
{
int x=-1,y=-1,z=-1,a;
a=(x++ && y++) || ++z;
printf("%d %d %d %d", x,y,z,a);
}
ans :0,0,-1,1
---------------26.
main()
{
int y=100,x;
x = y= y++;
printf("%d %d ", x,y);
}
ans : 100, 101
---------------27.
#include<stdio.h>
main()
{
int x,y=1,z;
if (z=(y==1)) x=5;
Page 28
C
else x=10;
printf("x=%d\t y = %d\t z=%d ",x,y,z);
}
ans:5 1 1
---------------28.
# include<stdio.h>
main()
{ int x,y=1,z;
if (z=y<0) x=3;
else
if (y==0) x=5;
else x=7;
printf ("%d %d %d",x,y,z);
}
ans : 7 1 0
-----------------29.
#include<stdio.h>
int i=0;
main()
{
auto int i=1;
printf("%d\n",i);
{
int i=2;
printf("%d\n",i);
{
i+=1;
printf("%d\n",i);
}
printf("%d\n",i);
}
printf("%d\n",i);
}
ans : 1 2 3 3 1
------------------30.
# include<stdio.h>
main()
{
int a=6;
a+= a++ + ++a;
printf("%d",a);}
ans : 22
-----------------31.
main()
{
static char food[]="yummy";
char *ptr;
ptr=food + strlen(food);
while (--ptr>=food)
puts(ptr);
}
ans : y
my
mmy
ummy
yummy
-------------------32.
main()
{
Page 29
C
int i =10;
#include<stdio.h>
printf("%d",i);
}
ans : 10
------------------33.
# define FUN(k) a+b/*d-bc*/c
main()
{
int a,b,c,*d,bc;
a=6;b=5;c=4;bc=2;
d=&c;
printf("%d\n",FUN(K));
}
ans : 8
------------------34.
main()
{
int x,a,b,c;
a=10;b=5;c=5;
x=a==b + c++;
printf("%d",x);
}
ans : 1
------------------35.
include<stdio.h>
main()
{
int *a=71;
printf("%d %d",a,*a);
}
ans : 71, garbage /*my comment : error in Unix. Core will be dumped*/
-------------------36.
# include<stdio.h>
main()
{
static int arr[]={ 97 ,98 ,99 ,100 ,101 ,102 ,103 ,104 };
int *ptr = arr+1;
print(++ptr,ptr--,ptr,ptr++,++ptr);
}
print(int *a,int *b,int *c,int *d,int *e)
{
printf("\n%d %d %d %d %d",*a,*b,*c,*d,*e);
}
ans : 100 100 100 99 99
--------------------37.
#include <stdio.h>
main()
{
int i;
int a[] = {1,2,3,4,5,6,7};
for(i=0;i<=4;i++)
{
printf(" %d ",a[i]);
}
}
ans : 1 2 3 4 5
----------------Page 30
C
38.
main()
{
int a,i;
i = 11;
a = i++ + ++i + --i;
printf("%d %d",a,i);
}
ans:33 12
----------------------39.
main()
{
int i=10;
printf("\n value of i =%d address of i =%u",i,&i);
&i==7200;
printf("\nnew value of i=%d new address of i =%u",i,&i);
}
ans : no change
-----------------------40.
main()
{
int *i,*j,**k;
j=i+2;
k =&i;
printf("\nk=%u j=%u i=%u",*k,j,i);
}
ans : addr pnted by i, addr pnted + 4, addr in i
-------------------41.
#include <stdio.h>
main()
{
union{
struct cathy{
int cathy;
char joe;
}cat;
int m;
}ass;
printf("\nsize of :%d " ,sizeof(ass));
}
ans : 3
----------------42.
#include<stdio.h>
main()
{
int i=3,j;
j= i++ * ++i * ++i;
printf("%d %d",j,i);
}
ans : 125 6
--------------43.
main()
{
int aa0aa1aa2aa3aa4aa5aa6aa7aa8aa9aazz1zz2 =10;
printf("%d",aa0aa1aa2aa3aa4aa5aa6aa7aa8aa9aa);
}
ans : 10 (Compiler dependent)
----------------44.
Page 31
C
#include<stdio.h>
main()
{
char in;
while ((in = getchar())!= '*')
{
if ((in >= 'a') && (in <='z'))
another();
}
}
another()
{
static int i=0;
i++;
printf("%d",i);
}
ans : if abc* is given as input then output is 123
--------------45.
#include<stdio.h>
main()
{
int stud[5][2]={
{1234,56},
{1212,33},
{1434,80},
{1312,78},
{1203,75}
};
int i,j;
for(i=0;i<=4;i++)
{
printf("\n");
for(j=0;j<=1;j++)
printf("%d",*(*(stud+i)+j));
}
}
ans: 123456
121233
143480
..
--------------46.
# include <stdio.h>
# define BYTESIZE
main()
{
int printbits(int);
int x =5;
printbits(~x);
}
printbits(x)
int x;
{
int i;
for(i=0;i<BYTESIZE*sizeof(x);++i)
printf("%d",(val <<i&1<<BYTESIZE*sizeof(int)-1)?1:0);
putchar('\n');
}
ans : error.
-----------------47.
#include <stdio.h>
main()
Page 32
C
{
int i=12,j=3,k =2;
/*
1 + 1 = 0 & 1+0 | 0+1 = 1 for XOR
/*
prece => compli ,AND,OR,XOR
printf("%d ",i^j&~k);
printf("%d %d",i & j,i & j && k);
}
ans : 13 0 0
------------48.
main()
{
/* !x gives 0 for +ive & -ive values ;one for 0
int x = 2;
printf("!x = %d\n",!x);
printf("%d\n",!x|x);
printf("%u\n",~x|x);
printf("%u\n",x<<1);
printf("%u\n ",x>>1);
}
ans : 0
2
65535 (Depends on the machine)
4
1
----------------49.
#include<stdio.h>
main()
{
int a,b,c;e
a = b =c= -1;
++a || ++b && ++c ;
printf("a = %d ,b = %d , c = %d",a,b,c);
}
ans : 0 0 -1
------------50.
#include<stdio.h>
main()
{
int a,b,c;
a = b = -2;
c = ++a && ++b ;
printf("a = %d ,b = %d , c = %d",a,b,c);
}
ans : -1 -1 1
-------------51.
#include<stdio.h>
main()
{
int x,y,z;
x = y = 0;
while(y <10)
{
x += ++y;
printf("%d
%d\n",x,y);
}
}
ans : 1 1
Page 33
*/
*/
*/
C
3 2
6 3
10 4
15 5
21 6
28 7
36 8
45 9
55 10
-------------52.
main()
{
int x=1,y=1;
if (y<0)
if (y>0) x=3;
else x=5;
printf("%d",x);
}
ans : 1
--------------53.
#include<stdio.h>
main()
{
int c,nd =0,no =0;
while((c =getchar())!= '\n')
switch(c) {
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
nd++;
default:
no++;
break;
}
printf("%d %d ",nd,no);
}
ans : when input is 123abc<enter> , nd=3 no = 6
------------------54.
main()
{
int x,y=1,z;
if (x=y=z);x=3;
printf("%d %d",x,z);
}
ans : x=3 z=garbage
---------------55.
main()
{
int a,b;
a =-3 - -3;
b =-3 - -(-3);
Page 34
C
printf("a = %d b =%d",a,b);
}
ans : a=0 b=-6
---------------56.
#include<stdio.h>
main()
{
long count;
count = 62000+1536+10;
printf("%ld ",count);
}e
ans : 63546
---------------57.
main()
{
long i;
i =65536+300;
printf("%ld ",i);
}
ans : 65836
--------------58.
main()
{
int *a;
*a = 1;
printf("%d %d",a,*a);
}
ans : garbage, 1
----------------59.
#include <stdio.h>
int a[][2] ={1,2,3,4};
main()
{
int i,j;
int (*p)[2]=a;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
printf("%u \t\t%u \n",*p+j,*(*p+j));
p++;
}
}
ans :
158
1
160
2
162
3
164
4
--------------60.
main()
{
int *a=1;
printf("%d %d",a,*a);
}
ans : 1, garbage
--------------61.
main()
{
char a[]={"jeban"};
Page 35
C
printf("%*s",(40+strlen(a)),a);
}
ans : 45 spaces + jeban
---------62.
#include <stdio.h>
void cube(int *,int *,int *);
main()
{
int x=5,y,z;
cube(&x,&y,&z);
printf("value of x =%d",x);
printf("\nIts cube =%d",z);
}
void cube(int *a,int *b,int *c)
{
*b = (*a)*(*a);
*c = (*b)*(*a);
}
ans: x=5 z=125
---------------63.
main()
{
int i=2,j=3,k;
k=i+++j;
printf("%d %d %d",i,j,k);
}
ans : 3 3 5
----------64.
compute(int m,int n)
{
if(m==0)
return(n+1);
else
{
if(n==0)
compute(m-1,1);
else
compute(m,compute(m-1,n));
}
}
main()
{
int i;
i = compute(2,3);
printf("%d",i);
}
ans : bull shitting question
-----------------65.
main()
{
int i=0;
char *cat ="city\0ki0ng";
while(*cat++)
{
i++;
printf("%d\n",i);
}
Page 36
C
}
ans : 1 2 3 4
-----------------66.
#include <stdio.h>
int i;
main()
{
char joe[10] = "city\0ki0ng";
char ch;
for(i=0;(ch=joe[i]!=0);i++)
{
ch=ch+'a'-'A';
printf("%d\n",ch);
}
}
ans : 33
33
33
..
-------------67.
#include <stdio.h>
main()
{
FILE *fp;
char str[20];
fp = fopen("new.out","w");
if(fp == 0)
printf("File opening error");
else
{
printf("Enter your name:");
scanf("%s",str);
fprintf(fp,"%s",str);
fclose(fp);
}
}
ans : too simple
---------------68.
#include <stdio.h>
main()
{
FILE *fp;
char a;
fp = fopen("old.out","w");
if(fp == 0)
printf("File opening error");
else
{
for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
fprintf(fp,"%c",a);
fclose(fp);
}
}
ans : same as the previous one
------------------69.
main()
{
int a=(10,15,12,77);
printf("%d ",a);
Page 37
C
}
ans : 77
----------------70.
main()
{
char a;
printf("%d",(2^3)+(a^a));
}
ans: 1
----------------71.
main()
{
int i = 5;
printf("%d",i);
return(991211233232132323232242243333322232344233232323232342342242422);
printf("hai");
}
ans : 5
----------------72.
main()
{
int i=4,*j,*k;
j=&i;
printf("\n%d\n",j);
j=j+1;
printf("\n%d\n",j);
j=j+9;
k=j+3;
printf("%d %d %d ",i ,j ,k);
}
ans : too simple
-------------73.
#include<stdio.h>
#include<conio.h>
#define CL printf("%c%c%c%c",27,91,50,74)
printf("%c%c%d%c%d%c",27,91,x,59,y,72)
#define VR printf("%c%c%c%c",27,91,55,109)
#define VB printf("%c%c%c%c",27,91,53,109)
#define VO printf("%c%c%c%c",27,91,53,109)
main()
{
CL;
MC(12,33);
printf("hai");
VR; /*macro for reverse video on */
printf("\nhallo");
VO; /*macro for reverse video off */
printf("\nbye" );
MC(17,25);
VB; /* macro for video blink */
printf("\nHELLO");
}
ans : prints some bull shit
--------------74.
main()
{
Page 38
#define MC(x,y)
C
printf("%d",0.3.);
}
ans : error.
---------------75.
main()
{
int a=3,b=2;
if (a=b)
printf("The two numbers are same");
else
printf("The two numbers are not same");
}
ans : two numbers are same
--------------76.
#include <stdio.h>
main()
{
char *s="abc";
char *t;
for (t=s;*t!='\0';++t)
{ switch (*t)
{
case 'a':
putchar('1');
case 'b':
putchar('2');
case 'c':
putchar('3');
break;
}
}
putchar('\n');
}
ans : 123233
------------------77.
#include <stdio.h>
main()
{
struct word
{
char *string;
int length;
};
struct word dict[2];
struct word *p =dict;
p->string = "structure";p->length =9;
(++p)->string ="word";p->length= 5;
printf("%d\n",(--p)->length);
printf("%c",*(p->string));
}
ans : 9 s
-----------------------78.
#include <stdio.h>
char *strchr(char *s,char c)
{
while(*s++!= c);
return s;
Page 39
C
}
main()
{
char str[30];
gets(str);
puts(strchr(str,'a'));
}
ans : input given "onometapoiea"; output is poiea
---------------79.
#include <stdio.h>
void main(void)
{
int i=5;
printf("\n%d",i);
change(i/2);
printf("\n%d",i);
i=change(i/2);
printf("\n%d",i);
}
int change(int i)
{
return i<=5 ? 2 : 5 ;
}
ans : 5 5 2
------------80.
#include <stdio.h>
main()
{
printf("%d",func());
}
int func()
{
_AX=100;
}
ans : 100
------81.
#include <stdio.h>
char *mycopy(str)
char *str;
{
char ptr[20];
strcpy(ptr,str);
return(ptr);
}
main()
{
char name[20];
char parm[20];
strcpy(name,"malini");
parm =mycopy(name);
puts(parm);
}
ans : error
--------------82.
# include<stdio.h>
Page 40
C
# include<ctype.h>
main()
{
char a;
a = getchar();
if isupper(a)
printf("entered value is upper");
else
printf("entered value is lower");
}
ans : input 'a'. output: entered value is lower
-------------83.
main ()
{
int a = 10,b=5;
a ^=b^=a^=b;
printf("%d %d ",a,b);
}
ans : 5 10
---------------84.
main()
{
float a=0.131200;
printf("%d ",a);
}
ans : 0
-----------------85.
#include <stdio.h>
main()
{
int *i,j;
i =&j;
i =i+ 5;
printf("%d %d",i,&j);
}
ans : (compiler dependent) &j+10, &j
---------------------86.
main()
{
char a[10],*pc;
int j;
pc = a;
pc
=pc + sizeof(a);
j=pc-a;
printf("%d",j);
}
ans : 20
-------------------------------------------
Page 41