Академический Документы
Профессиональный Документы
Культура Документы
TUTORIAL-I
5. main()
{
int x;
printf(“\n%d”,x=20,x=30,x=40);
printf(“%d”,x);
}
6. main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d%d%d%d%d",i,j,k,
l,m);
}
7. #include<stdio.h>
main()
{ int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}}
8. main()
{
int i;
for(i=0;i<=2;i++)
{
switch(i)
{
case 1: printf(“%d”,i);
case 2: printf(“%d”,i);
default: printf(“%d”,i);
} }}
10. main()
{
int i=5;
printf("%d%d%d
%d%d%d",i++,i--,++i,--i,i);
}
11. main()
{
int a=10;
int b=6;
if(a=3)
b++;
printf(“%d %d\n”,a,b++);
}
12. main()
{
int x;
printf(“\n%d”,x=20,x=30,x=40);
pritnf(“%d”,x);
}
13. main( )
{
int a,b;
a=10, b=20;
printf(“%d”,a,b);
}
15. main()
{
int a,b;
printf(“enter two numbers”);
scanf(“%d %d”,a,b);
printf(“%d + %d = %d”,a,b,a+b);
}
16. main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
17. main()
{
int a,b;
a=10, b=20;
printf(“%d”,a,b);
}
18. main()
{ int c= - -2;
printf("c=%d",c);
}
19. #include<stdio.h>
main()
{
int a=100;
printf(“%d%d%d”, a++,a,++a);
}
20. main()
{
int i=5,j=6,z;
printf("%d",i+++j);
}
21. main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("Equal");
else
printf("Not Equal"); }
22. main()
{
int i=10;
i=!i>14;
printf(“i=%d”,i);
}
23 . main(){
int a= 0;int b = 20;
char x =1;char y =10;
if(a,b,x,y)
printf("hello"); }
24. main()
{
int y;
scanf("%d",&y);
if( (y%4==0 && y%100 != 0) ||
y%100 == 0 )
printf("%d is a leap year");
else
printf("%d is not a leap year");
}
If input given is 2000, What is the output?
25. main()
{
int x=6;
switch(x)
{
default: x+=2;
case 4: x=4;
case 5: x++;
break;
}
printf(“%d”,x);
}
29. main()
{
char p;
printf(“%d”,sizeof(p));
}
30. main()
{
printf(“%x”,-1<<4);
}
TUTORIAL-II
a. main()
{
extern int i;
i=20;
printf("%d",i);
}
b. main()
{
extern out;
printf("%d", out);
}
int out=100;
c. main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main(); }
a. main()
{
while(strcmp(“some”,”some\0”)) printf(“Strings are not equal\n”);
}
b. main()
{
char str1[] = {„s‟,‟o‟,‟m‟,‟e‟};
char str2[] = {„s‟,‟o‟,‟m‟,‟e‟,‟\0‟};
while(strcmp(str1,str2))
printf(“Strings are not equal\n”);
}
c. #include<stdio.h>
main()
{
if(“string”==”string”)
printf(“Both the strings are Equal”);
else
printf(“Both the strings are Not Equal”);
}
d. main()
{
char a[4]="HELL";
printf("%s",a);
}
e. void main()
{
char a[]="12345\0";
int i=strlen(a);
printf("here in 3 %d\n",++i);
}
a. main()
{
int a[]={10,20,30};
int *ip, i;
ip=a;
for(i=0;i<2;i++)
{
printf(“%d”,*ip);
}
}
a. 10 20 30 b. 10 20 c. 1 2 3 d. error
b. main()
{
char a[4]={„H‟,‟E‟,‟L‟,‟L‟,‟\0‟};
printf("%s",a);
}
a. HEL b. HELL
c. compiler error ( too many values in initialization )
d. none of the above
c. main()
{
char a[4]="HELL";
printf("%s",a);
}
a. HEL b. HELL c. compiler error d. none of the above
TUTORIAL-III
1. main()
{
int a[]={10,20,30};
int *ip, i;
ip=a;
for(i=0;i<2;i++)
{
printf(“%d”,*ip);
}
}
a. 10 20 30 b. 10 20
c. 1 2 3 d. error
4. void main()
{
int count=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
}
a. 10, 20,20 b. 20 20 20
c. 20 10 10 d. 20 20 10
8. main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[i],
*(s+i),*(i+s),i[s]);
}
a. man
b. mmmm
c. mmmm
aaaa
nnnn
d. Compiler Error
9. main()
{
char *p;
printf("%d%d",
sizeof(*p),sizeof(p));
}
a. 1 2 3 b. 1 2
c. compiler error
d. None of the above
11. #include<stdio.h>
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);
}
a. 100 b. abc c.77 d.101
13. main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
a. Hello b. H c. He d. Hell
14. main( )
{
int a[2][3][2]=
{{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf(“%u%u%u %d \n”,a,*a,**a,***a);
printf(“%u%u%u%d\n”,a+1,*a+1,**a+1,***a+1);
}
a. 100, 100, 100, 2
114, 104, 102, 3
b. 100,100,100,100
c. 101,102, 200, 202
d. 100, 101,102,103
15. main( )
{
static int a[ ] = {0,1,2,3,4};
int *p[ ] = {a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
*ptr++;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
*++ptr;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
++*ptr;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
}
a. 111
222
333
344
b. 1234
1234
1234
1234
c.1234
d.1111
16. 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);
}
a. g20fy b.20
c. fy d. None of the above
17. main()
{
int *j;
{
int i=10;
j=&i;
}
printf("%d",*j);
}
a. 100 b.10
c.Compiler error d. None
18. # 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.3 b. hello
c. bye d. None of the above
19. main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);
}
20. main()
{
int a[10];
printf("%d",*a+1-*a+3);
}
a. 2 b. 4 c.3 d. Error
21. If address of a is 4000 then what is the output?
main()
{
int a=5,*p;
p=&a;
p=p+2;
printf(“%u”,p);
printf(“%u”,++p)
}
a.4000 4001 b. 4001 4002
c. 4002 4004 d. 6 7
Course Coordinator Module Coordinator