Class Notes (835,376)
Canada (509,147)
CMPT 129 (2)
Lecture 8

CMPT 129 Lecture 8: 3.3 - Counting Vowels

3 Pages
68 Views
Unlock Document

Department
Computing Science
Course
CMPT 129
Professor
Janice Regan
Semester
Spring

Description
#include #include using namespace std; int main () { // This program reads a string of characters from the keyboard // The end of the string of characters in indicated by a tab // The program then reads // one character at a time determining if that character is a vowel. // The program also counts the number of occurences of each vowel // (a,e,i,o,u,y) in the string and the number of non whitespace // characters in the string that are not vowels. // The number of each vowel counted and the number of non // vowel characters counted are summarized after all characters in // the string have been analysed and counted // Creation data Sept. 23, 2013 // Program Author: Janice Regan // declare variables // Note: separate counters are defined for each vowel, for other // characters. (countA, countE, countI, countO, countY, countOther) char nextChar; // next character from file char answer; // answer, program continues if y or Y int nscan; // number of characters read (EOF if nscan <=0) int countA; // counter to record number of As int countE; // counter to record number of Es int countI; // counter to record number of Is int countO; // counter to record number of Os int countU; // counter to record number of Us int countY; // counter to record number of Ys int countOther; // counter to record number of other characters //initialize answer, so test in infinite while loop for next string is true answer = 'y'; while (answer == 'y' || answer == 'Y') { // initialize counters filename, and filepointer // Must be reinitialized for each new file, so initialization is // inside loop countA = 0; countE = 0; countI = 0; countO = 0; countU = 0; countY = 0; countOther = 0; nscan = 1; // initialize nextChar so test is infinite while loop to read next // character is true nextChar = ' '; /
More Less

Related notes for CMPT 129

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit