Write a program to display the String in Upper Case, Lower Case, in reveres order, copy one string into another also calculate its length and compare two String. - WAY2IT

Latest Post :

Home Top Ad

Write a program to display the String in Upper Case, Lower Case, in reveres order, copy one string into another also calculate its length and compare two String.



Code :-

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s1[20],s2[20];
int l;
clrscr();
printf("enter a string\n");
scanf("%s",&s1);
l=strlen(s1);//length of string
printf("\nLength of the string is %d",l);
strupr(s1);//capital letters
printf("\ns1 in Upper Case is %s",s1);
strlwr(s1);//lower case
printf("\ns1 in lower case is %s",s1);

strcpy(s2,s1);//copy s1 into s2
printf("\nCopy Strinf s1 into s2 is %s",s2);
strcat(s1," patel");// or strcpy(s1,s2) --> add s2 to s1
printf("\nConcated String s1 with Patel is %s",s1);
strrev(s1);//reverse the string
printf("\nreversed order of s1 is %s",s1);
getch();
}


Output :-