String 1
String 1
1) int main()
{
char str1[20] = "ashok", str2[20] = "linux";
printf("%s\n", strcpy(str2, strcat(str1, str2)));
return 0;
}
2) #include<stdio.h>
int main()
{
char p[] = "%c\n";
p[1] = '%';
printf(p,77);
return 0;
}
3) int main()
{
printf("%d\n", strlen("ashok"));
return 0;
}
4) int main()
{
char str[] = "vector\0\Bindia\0";
printf("%s\n", str);
return 0;
}
5) int main()
{
printf("vector", "INDIA\n");
return 0;
}
6) int main()
{
char str[7] = "vectorchennai";
printf("%s\n", str);
return 0;
}
7) int main()
{
char str[] = "chennai\0\Bvector\0";
printf("%d\n", strlen(str));
return 0;
}
8) int main()
{
static char str1[] = "Msd";
static char str2[20];
static char str3[] = "Rohit";
int i;
i = strcmp(strcat(str3, strcpy(str2, str1)), "RohitMsd");
printf("%d\n", i);
return 0;
}
9) int main()
{
static char s[] = "ashok!";
printf("%d\n", *(s+strlen(s)));
return 0;
}
return 0;
}
int main()
{
char str[10]="Hello";
str[strlen(str)+1]='#';
printf("str= %s\n",str);
return 0;
}
while(*ptr!='\0')
printf("%c",++*ptr++);
printf("\n");
return 0;
}
while(loop<5)
printf("%02X ",str[loop++]);
printf("\n");
return 0;
}
if (strcmp(str, str1))
printf("equal");
else
printf("unequal");
}
29) int main()
strcpy(str, str1);
printf("%s", str1);
char str1[9];
printf("%d", strlen(str));
}
32) int main()
strcat(str, str1);
printf("%s", str);
34) main()
{
const char str1[]="ABCDEF1234567";
const char str2[] = "269";
int len = strcspn(str1, str2);
printf("Ashok=%d\n", len + 1);
}
38) #include<stdio.h>
#include<string.h>
int main()
{
char str1[20] = "Hello", str2[20] = " World";
printf("%s\n", strcpy(str2, strcat(str1, str2)));
return 0;
}
40)
int main()
{
printf(5+"Gud Morning\n");
return 0;
}
strncpy(s2,s1,8);
printf("%s\n",s2);
return 0;
}
while(str+strlen(str))
printf("*");
return 0;
}
58) main()
{
char c[] = "vector2020";
char *p =c;
printf("%c %c\n", *p,*(p+p[3]-p[1]));
}
59) #include<stdio.h>
main()
{
char p[20];
char *s = "string";
int length = strlen(s);
int i;
for (i = 0; i < length; i++)
p[i] = s[length-i];
printf("%s",p);
printf("hai\n");
}
60) main()
{
char c[] = "inda2020";
char *p =c;
printf("%s", p + p[3] - p[1]) ;
}
61) #include<stdio.h>
int main()
{
char p[] = "%c\n";
p[1] = '%';
printf(p, 77);
return 0;
}
62) #include<stdio.h>
int main()
{
char p[] = "%%\n";
p[0] = '/';
printf(p[0], 'A');
return 0;
}
63) #include<stdio.h>
int main()
{
char p[] = "%f\n";
p[0] = 'f';
p[0++];
printf(p[0], 'Z');
return 0;
}
64) #include<stdio.h>
int main()
{
char p[] = "%f\n";
p[0] = 'f';
if(1)
//p[0++];
printf(p, 'Z');
return 0;
}
65) #include<stdio.h>
int main()
{
char p[] = "%f\n";
p[0] = 'f';
if(!!1)
//p[0++];
printf(p, 'Z');
return 0;
}
66) #include<stdio.h>
int main()
{
printf("welcome");
char p[] = "%f\n";
p[0] = 'f';
if(!!1&&1)
return;
printf(p, 'Z');
return 0;
}
67) #include<stdio.h>
int main()
{
printf("vector");
char p[] = "%f\n";
p[0] = 'f';
if(~0)
printf(p+1, 'Z');
return 0;
}
68) #include<stdio.h>
int main()
{
printf("vector");
char p[] = "%s\n";
p[0] = 's';
if(~0&&~1)
printf(p+2, 'A');
return 0;
}
69) #include<stdio.h>
int main()
{
printf("vector");
char p[] = "%s\n";
p[0] = 's';
if(~0||~1)
printf(p+2, 'A');
return 0;
}
70) #include<stdio.h>
int main()
{
char p[] = "%s\n";
p[1] = 'S';
if(p[0])
printf(p,'1');
return 0;
}
106) main()
{
char s[]= "string";
int length = strlen(s);
int i;
for (i = 0; i < length; i++)
printf("%c", s[i]);
}
107) main()
{
char str1[] = "positivity";
if(printf("%d\n",sizeof(str1)) )
{
printf("if u win\n");
}
else
{
printf("no one win\n");
}
}
112) main()
{
char str[]="Clock";
printf("%.3s\n",str);
}
113) main()
{
char str[]="sklinux";
printf("%1.3s\n",str);
}
114) main()
{
char str[]="sklinuxchennai";
printf("%7.2s\n",str);
}
115) main()
{
char str[]="sklinuxbanglore";
printf("%0.2s\n",str);
}
116) main()
{
char x[]="hi";
char y[]="hello";
printf("%s",x+y);
}
117) main()
{
char sport[]="cricket";
int x=1,y;
y=x++ + ++x;
printf("%c",sport[++y]);
}
118) main()
{
char p[]="star",q[10];
strcpy(q,p);
printf("%s,%s","ashok",q);
}
119) main(){
char name[]="India";
int i;
for(i=0;i<strlen(name);i+=2){
printf("%c",name[i]);
}
}
120) main()
{
char str[]="C For Swimmers";
printf("%.5s\n",str);
}
121) main()
{
char line[80]="Dear Friends";
printf("%1.2s",line);
}
122) main()
{
char *str="NULL";
strcpy(str,"Cquestionbank");
printf("%s",str);
}
123) main()
{
char a[]="India";
char *p="BITS";
a="BITS";
p="India";
printf("%s %s",a,p);
}
124) main()
{
char *x="HELLO";
x+=3;
printf("%s",x);
}
}
127) int main()
{
int i;
char str[]="Borntowin";
for(i=0;str[i]!='\0';i++)
{
continue;
putchar(str[i]);
putchar('*');
}
printf("break");
}
130) int main()
{
int i;
char str[]="Borntowin";
printf("exit");
while(1)
{
exit(0);
putchar(str[i]);
putchar('*');
}
}
133) int main()
{
int i;
char str[]="Borntowin";
if(str)
{
putchar(str[i]);
putchar('*');
}
}
137) int main()
{
int i=0;
char str[]="Borntowin";
while(str[i])
{
putchar(str[++i]);
++i;
}
}
141) int main()
{
int i=0,k='a';
char str[]="Borntowin";
do
{
putchar('k');
break;
++i;
}while(i&&k);
}
145) int main()
{
char str[]="res=%d";
int a='7';
int b='8';
str[11]='c';
printf(str,b);
return 0;
}
return;
}
187) int main()
{
while(1)
if(printf("%s","while(1)"));
return 0;
while(printf("%d",(printf("s"))))
return;
}
return;
}
}
return;
}
printf("while(!1)");
}
return;
}
printf("while(!1)");
}
191) main()
{
printf("hi");
while(main())
{
while(printf("while(!1)"));
{
while(!1);
if(printf("%s","while(!1)"));
return 0;
while(printf("%d",(printf("s"))))
return;
}
printf("while(!1)");
}
}
192) main()
{
printf("hi");
break;
while(main())
{
while(printf("while(!1)"));
{
while(!1);
if(printf("%s","while(!1)"));
return 0;
while(printf("%d",(printf("s"))))
return;
}
}
printf("while(!1)");
}
193) main()
{
switch(0)
{
printf("hi");
case 0:while(printf("while(!1)"));
break;
{
while(!1);
if(printf("%s","while(!1)"));
return 0;
while(printf("%d",(printf("s"))))
return;
}
}
}
194) main()
{
switch(0)
{
case 0:while(printf("ashok"))
return;
{
while(!1);
if(printf("%s","while(!1)"));
return 0;
while(printf("%d",(printf("s"))))
return;
}
}
}
195) main()
{
switch(0)
{
default:printf("vector");break;
case 01:while(printf("ashok"))
return;
{
while(!1);
if(printf("%s","while(!1)"));
return 0;
while(printf("%d",(printf("s"))))
return;
}
}
}
196) main()
{
if("a")
{
break;
case 1:while(printf("ashok"))
return;
}
else
printf("Switch");
}
197) main()
{
if("a")
{
switch("a")
case 97:while(printf("ashok"))
return;
}
else
printf("Switch");
}
198) main()
{
if("a")
{
switch('a')
case 97:while(printf("ashok"))
return;
}
else
printf("Switch");
}
199) main()
{
if("a")
{
switch('a'++)
case 97:while(printf("97"))
return;
}
else
printf("Switch");
}
200) main()
{
if("a")
{
switch(200)
case 20:while(printf("200"))
return;
}
if("a")
printf("Switch");
}
Answers:
---------
1)ashoklinux
2)A
3)5
4)vector
5)vector
6)vectorc
7)7
8)0
9)0
10)hhe!
11)i am the best
12)9,4,1,1
13)ashok
14)21
15)Garbage
16)segmentation fault
17)compile error
18)slaog ruoy wolloF
19)segmentation fault
20)1
21)Garbage,hai
22)22
23)o world,o world
24)Hello
25)ABC D
26)joejb
27)00 00 00 00 00
28)unequal
29)segmentation fault
30)hello, wo 9
31)13
32)helloworld,0
33)helloworld
34)Ashok=8
35)1,4,4
36)e
37)FOLLOW YOUR PASSION
38)Hello World
39)A
40)orining
41)globe
42)globy
43)A| Ag Ag
44)AL Ag Ag
45)BRAZIL
46)GOAT
47)GOAT
48)ZILLA
49)segmentation fault
50)B*o*r*n*t*o*w*i*n*
51)value is = 7
52)FALSE
53)HelloFriends
54)haihelloaihello
55)hai,ai,i
56)compile error
57)infinite
58)7
59)hai
60)Garbage
61)%
62)segmentation fault
63)compile error
64)ff
65)ff
66)welcome
67)vectorf
68)vector
69)vector
70)segmentation fault
71)d
72)tor
73)dvector
74)dvector
75)f
76)u
77)u
78)%%
79)compile error
80)segmentation fault
81)vectorccindia
82)vector\d\dindia
83)vector\r\india
84)vectorindia
85)indiar
86)indiaector
87)sindiavector
88)exit
89)exit
90)exit
91)compile error
92)vector
93)vecto
94)Garbage
95)segmentation fault
96)v
97)w
98)v
99)compile error
100)Garbage
101)n1=12,n2=10
102)ver ver ver e e e
103)Happy
104)20
105)9
106)string
107)11,if u win
108)104,h
109)indiavector
110)vectorindia
111)compile error
112)Clo
113)skl
114) sk
115)sk
116)compile error
117)e
118)ashok,star
119)Ida
120)C For
121)De
122)segmentation fault
123)compile error
124)lo
125)break
126)break
127)break
128)exit
129)compile error
130)exit
131)*
132)*
133)segmentation fault
134)B*
135)infinite
136)Brtwn
137)onoi
138)compile error
139)kkkkk
140)k
141)k
142)infinite
143)ev
144)unconditional
145)res=56
146)3080
147)1
148)1
149)res=57
150)res=57
151)d
152)u
153)compile error
154)compile error
155)char str[10]=
156)infinite
157)char str[10]=
158)vector
159)infinite
160)vector
161)india
162)chennai
163)infinite
164)s
165)success
166)hisuccess
167)hi
168)hi
169)return
170)infinite
171)chennai,exit
172)chennai,return
173)compile error
174)compile error
175)2
176)1
177)1,2
178)compile error
179)infinite
180)1,2
181)infinite
182)infinite
183)s1,bye2
184)s
185)s,1
186)while(1)
187)infinite
188)while(!1)
189)while(!1)
190)infinite
191)infinite
192)compile error
193)infinite
194)ashok
195)vector
196)compile error
197)compile error
198)ashok
199)compile error
200)Switch