C program to convert a sentence in upper case letter to lower .
In this tutorial we will learn how to write a c program that convert the sentence upper to lower and vice versa.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int x;
char str1[100],str2[100]={0};
printf("\n ENTER A SENTENCE TO CONVERT UPPER TO LOWER:\n \n ");
gets(str1);
for(x=0;x<strlen(str1);x++)
{
if(str1[x]>='a'&&str1[x]<='z')
{
str2[x]=(char)str1[x]-32;
}
else if(str1[x]>='A'&&str1[x]<='Z')
{
str2[x]=(char)str1[x]+32;
}
else
{
str2[x]=str1[x];
}
}
printf("\n THE CONVERTED SENTENCE IS:-\n\n %s\n ",str2);
getch();
}
In this tutorial we will learn how to write a c program that convert the sentence upper to lower and vice versa.
C program code
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int x;
char str1[100],str2[100]={0};
printf("\n ENTER A SENTENCE TO CONVERT UPPER TO LOWER:\n \n ");
gets(str1);
for(x=0;x<strlen(str1);x++)
{
if(str1[x]>='a'&&str1[x]<='z')
{
str2[x]=(char)str1[x]-32;
}
else if(str1[x]>='A'&&str1[x]<='Z')
{
str2[x]=(char)str1[x]+32;
}
else
{
str2[x]=str1[x];
}
}
printf("\n THE CONVERTED SENTENCE IS:-\n\n %s\n ",str2);
getch();
}
OUTPUT:
In this output we can see that we will enter a sentence and it is convert upper case letter to lower case letter and lower case letter to upper case letter.
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
Created by-- HARSH CHAUHAN
No comments:
Post a Comment