How to accept a string in any case and print it by another case in C++ Program

CWC
0 Min Read

C++ Program to accept a string in any case and print it by another case.

# include 
#include
#include
using namespace std;
int main( )
{
char ch;
cout<<"enter a string :"; while(( ch=getchar( ))!='\n') { if(ch>='A' && ch<='Z') putchar(ch+32); else if(ch>='a' && ch<='z') putchar(ch-32);
else putchar(ch);
}
cout<<"is the string";
return 0;
}
Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version