String Practice Sheet
String Practice Sheet
void main()
if(str1==str2)
printf("Equal");
else
printf("Unequal");
void main()
printf(“>>%s<<\n”,s);
printf(“>>%20s<<\n”,s);
printf(“>>%-20s<<\n”,s);
printf(“>>%.4s<<\n”,s);
printf(“>>%-20.4s<<\n”,s);
printf(“>>%20.4s<<\n”,s);
(i) char str[]={‘h’, ‘e’, ‘l’, ‘l’, ‘o’}; (ii) char str[5]={‘h’, ‘e’, ‘l’, ‘l’, ‘o’, ‘\0’};
(iii) char str[]={‘h’, ‘e’, ‘l’, ‘l’, ‘o’, ‘\0’}; (iv) char str[6]={‘h’, ‘e’, ‘l’, ‘l’, ‘o’, ‘\0’};
52. Write a C program that reads the name of a person as input and print the name in an abbreviated
fashion, e.g., Dennis Ritchie as D.R.
53. Write a program to store name of ten cities and rewrite it in alphabetical order.
#include<string.h>
int main()
return 0;
b. #include<stdio.h>
int main()
p[1] = 'c';
printf(p, 65);
return 0;
c. #include<stdio.h>
#include<string.h>
int main()
printf("%d\n", strlen("123456"));
return 0;
}
d. #include<stdio.h>
int main()
int i=0;
char ch;
ch = s[++i];
printf("%c", ch);
ch = s[i++];
printf("%c", ch);
ch = i++[s];
printf("%c", ch);
ch = ++i[s];
printf("%c", ch);
return 0;