Write a program to convert the alphabets of lower class to upper class and vice versa.
Answers
Answered by
5
# include<iostream>
using namespace std;
int main()
{
char a[30];
cout << "Enter a string";
cin >> a;
for(int i = 0; a[i]!='\0';i++)
{
if(a[i] >= 97 && a[i] <= 132)
a[i]=a[i] - 32;
else
a[i] = a[i] + 32;
}
cout << "Uppercase is: "<<a;
}
Output:
Enter a string : Siddhartha
Uppercase is : SIDDHARTHA.
Hope it helps!
Attachments:
siddhartharao77:
wlcm
Answered by
7
Note: By a ASCII character, here, "a" has the output Html of 97 and between those characters by a starting extractor operation it's going to be, "a" - "A" = 32, for an exact encoding.
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
clrscr();
char ch;
cout << "Submit any Alphabet you like";
cin >> ch;
if(ch>='a' && ch<='z')
{
cout << "You have submitted a lower case alphabet. ";
ch = ch-32;
cout << "The Upper case alphabet, here, will be: "<<ch;
}
else
{
cout << "You have submitted a Upper case alphabet. ";
ch = ch+32;
cout << "The lower case alphabet, here, will be: "<<ch;
}
getch();
}
By submitting a upper case alphabet: Vishwas
The lower case alphabet for first letter is going to be: vishwas
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
clrscr();
char ch;
cout << "Submit any Alphabet you like";
cin >> ch;
if(ch>='a' && ch<='z')
{
cout << "You have submitted a lower case alphabet. ";
ch = ch-32;
cout << "The Upper case alphabet, here, will be: "<<ch;
}
else
{
cout << "You have submitted a Upper case alphabet. ";
ch = ch+32;
cout << "The lower case alphabet, here, will be: "<<ch;
}
getch();
}
By submitting a upper case alphabet: Vishwas
The lower case alphabet for first letter is going to be: vishwas
Similar questions