BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/322-object-oriented-programming/)
-   -   Program to enter a sentence and output the number of uppercase & lowercase consonants, uppercase & lowercase vowels in senten (http://bzupages.com/f322/program-enter-sentence-output-number-uppercase-lowercase-consonants-uppercase-lowercase-vowels-senten-14668/)

bonfire 09-03-2011 12:22 AM

Program to enter a sentence and output the number of uppercase & lowercase consonants, uppercase & lowercase vowels in senten
 
1 Attachment(s)
Program to enter a sentence and output the number of
uppercase & lowercase consonants, uppercase & lowercase vowels in sentence.



#include
#include

void main()
{
clrscr();
char line[80];
int number_of_vowels,uc,lc,uv,lv;
uc=lc=uv=lv=0;
cout << "Enter your sentence : " << endl;
cin.getline(line,80);
for(int x=0; line[x]!='\0';x++)
{
if(line[x]=='A'||line[x]=='E'||line[x]=='I'||line[x]=='O'||line[x]=='U')
uv++;
else if(line[x]=='a'||line[x]=='e'||line[x]=='i'||line[x]=='o'||line[x]=='u')
lv++;
else if(line[x]>+65&&line[x]<=90)
uc++;
else if (line[x]>=97&&line[x]<=122)
lc++;
}
//Printing the output.
cout << "Uppercase Consonants = " << uc << "." << endl;
cout << "Lowercase Consonants = " << lc << "." << endl;
cout << "Uppercase Vowels = " << uv << "." << endl;
cout << "Lowercase Vowels = " << lv << "." << endl;
number_of_vowels=uv+lv;
cout << "Number of vowels = " << number_of_vowels << endl;
getch();
}
This program takes in a sentence as a screen input from the user.
It then computes the number of uppercase and lowercase consonants, uppercase and lowercase vowels and the total number of vowels.
It then outputs it using the 'cout' command.


Sample Input
These programs are truly AMAZING
Sample Output
Uppercase Consonants = 5.
Lowercase Consonants = 13.
Uppercase Vowels = 3.
Lowercase Vowels = 7.
Number of vowels = 10


All times are GMT +5. The time now is 09:32 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.