-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlphabet.cpp
More file actions
118 lines (98 loc) · 2.67 KB
/
Copy pathAlphabet.cpp
File metadata and controls
118 lines (98 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// WAP to check if a character is alphabet.
// Write a program to input any character and check whether it is alphabet, digit or special character.
// Write a program to check whether a character is uppercase or lowercase alphabet.
// Write a program to input any alphabet and check whether it is vowel or consonant.
#include<iostream>
using namespace std;
void alphabet(char ch) //Checking for alphabet.
{
cout <<"Enter a character"<<endl;
cin >>ch;
if(ch>64&&ch<91)
cout <<"\n Character is a alphabet";
else if(ch>98&&ch<123)
cout <<"\n Character is a alphabet";
else
cout <<"\n Character is not a alphabet";
}
void character(char ch) //Checking for alphabet,digit or special character.
{
cout <<"Enter a character"<<endl;
cin >>ch;
if((ch>=65&&ch<=90)||(ch>=97&&ch<=122)) //Checking for Alphabet
cout <<"\n Character is a Alphabet";
if(ch>=48&&ch<=57) //Checking for Digits
cout <<"\n Character is a Digit";
if((ch>=32&&ch<=47)||(ch>=58&&ch<=64)||(ch>=91&&ch<=96)||(ch>=123&&ch<=126)) //Checking for Special Character
cout <<"\n Character is a Special Character";
}
void upperCase(char ch) //Checking upper case or lower case.
{
A:cout <<"Enter an alphabet"<<endl;
cin >>ch;
if((ch>=65&&ch<=90)||(ch>=97&&ch<=122)) //Checking for Alphabet
{
if(isupper(ch))
cout <<"\n Alphabet is Upper Case";
else
cout <<"\n Alphabet is Lower Case";
}
else
{
cout<<"INVALID INPUT"<<endl;
goto A;
}
}
void vowel(char ch) //Checking for vowel.
{
A:cout <<"Enter a alphabet"<<endl;
cin >>ch;
if((ch>=65&&ch<=90)||(ch>=97&&ch<=122)) //Checking for Alphabet
{
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'||ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u') //Checking for Vowel
cout <<"\n Given alphabet is a Vowel";
else
cout <<"\n Given alphabet is a Consonant";
}
else
{
cout<<"INVALID INPUT"<<endl;
goto A;
}
}
int main()
{
char ch;
int choice;
Repeat: cout <<"Enter the choice accordingly: \n 1) To check if character is an Alphabet \n 2) To check if caracter is an Alphabet or Digit or Special Character \n 3) To check if Alphabet is Uppercase \n 4) To check if Alphabet is a vowel"<<endl;
cin >>choice;
switch(choice)
{
case 1:
{
alphabet(ch);
break;
}
case 2:
{
character(ch);
break;
}
case 3:
{
upperCase(ch);
break;
}
case 4:
{
vowel(ch);
break;
}
default:
{
cout<<"\n Wrong choice entered. Please Enter a Correct choice \n"<<endl;
goto Repeat;
}
}
return 1;
}