C program to input a string from the user. Use appropriate built-in string functions to find the length of the string, copy 1 string to another, convert to uppercase, convert to lowercase, string comparison, string comparison irrespective of case, comparison of n characters in 2 strings, string concatenation, concatenation of ‘n’ of characters, reverse a string
c
program to input a string from the user. Use appropriate built-in
string
functions to find the length of the string, copy 1 string to another,
convert
to uppercase, convert to lowercase, string comparison, string
comparison
irrespective of case, comparison of n characters in 2 strings, string
concatenation,
concatenation of ‘n’ of characters, reverse a string.*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int
l,comp,cmp;
char
str[10], s1[10], s2[10], cat[20];
clrscr();
printf("Enter
1st String : ");
gets(str);
l=strlen(str);
printf("\nThe
length of the String : %d",l);
strupr(str);
printf("\nIn
UPPERCASE : %s",str);
strlwr(str);
printf("\nIn
lowercase : %s",str);
strrev(str);
printf("\nIn
Reverse : %s",str);
printf("\n\nEnter
two strings : ");
scanf("%s
%s",&s1,&s2);
cmp=strcmp(s1,s2);
if(cmp==0)
printf("\nStrings
are equal");
else
printf("\nStrings
are not equal");
strcat(s1,s2);
printf("\n\nString
Concatenation : %s",s1);
strcpy(s1,s2);
printf("\nString2
copied into String1 : %s",s1);
getch();
}
/*Output
Enter 1st String : yahoo
The length of the String : 5
In UPPERCASE : YAHOO
In lowercase : yahoo
In Reverse : oohay
Enter two strings : yahoo
yahoo
Strings are equal
String Concatenation : yahooyahoo
String2 copied into String1 : yahoo
*/