Q.WAP to read a string and print it after replacing each
of its capital alphabets by the corresponding small alphabet
and each small alphabet by its corresponding capital alphabet.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
void main()
{
clrscr();
char ch[30];
cout<<"Input a string:";
gets(ch);
cout<<"Original string is:";
puts(ch);
for(int i=0;ch[i]!='\0';i++)
{
if(isupper(ch[i]))
{
ch[i]=tolower(ch[i]);
}
if(islower(ch[i]))
{
ch[i]=toupper(ch[i]);
}
}
cout<<"Altered string is:";
puts(ch);
getch();
}
of its capital alphabets by the corresponding small alphabet
and each small alphabet by its corresponding capital alphabet.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
void main()
{
clrscr();
char ch[30];
cout<<"Input a string:";
gets(ch);
cout<<"Original string is:";
puts(ch);
for(int i=0;ch[i]!='\0';i++)
{
if(isupper(ch[i]))
{
ch[i]=tolower(ch[i]);
}
if(islower(ch[i]))
{
ch[i]=toupper(ch[i]);
}
}
cout<<"Altered string is:";
puts(ch);
getch();
}
No comments:
Post a Comment