Friday, August 26, 2011

CONVERT SENTENCE FROM UPPER LETTER TO LOWER LETTER AND VICE VERSA IN C/C++

This program will ask user to enter any string, If the user enter string in upper case the program will convert it into lower case and vice versa.

This program is capable of handling character and string.

CODING
 
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
main()
{
int l;
char ch[40];
cout<<"Enter a Character or sentence ";
gets(ch);
l=strlen(ch);
for(int a=0; a<=l; a++)
{
    if(ch[a]>=65 && ch[a]<=90)
        {
            ch[a]=ch[a]+32;
        }
else if(ch[a]>=97 && ch[a]<=122)
{
    ch[a]=ch[a]-32;
}
}
for(a=0; a<=l; a++)
    cout<<ch[a];
    cout<<endl;
getche();
clrscr();
}

No comments:

Post a Comment