Lab2Q7 (2).cpp - #include <iostream> using namespace std bool isVowel(char v if v ='a | v ='e | v ='i | v ='o | v ='u | v ='A | v ='E | v ='I | v ='O |

Lab2Q7 (2).cpp - #include <iostream> using namespace std...

This preview shows page 1 - 2 out of 2 pages.

#include <iostream> using namespace std; bool isVowel(char v){ if( v == 'a' || v == 'e' || v == 'i' || v == 'o' || v == 'u' || v == 'A' || v == 'E' || v == 'I' || v == 'O' || v == 'U'){ return true; } return false; } int foundLetter(char letter[], int size, char x){ for(int i=0; i<size; i++){ if(letter[i] == x) return i; } return -1; } void printArray(int arr[], int size){ for (int i= 0; i< size; i++) cout<<arr[i]<<"\t"; cout<<endl; } void printArrayChar(char arr[], int size){ for (int i= 0; i< size; i++) cout<<arr[i]<<"\t"; cout<<endl; } int main (){ char letters[] = {'a', 'b', 'c', 'b', 'a', 'a', 'a', 'a', 's', 's'}; char most; char least; int sizeU = 0; int countU[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; char unique[10]; int uniqueIndex = 0; int vowelsCount = 0; int consequenceCount = 1; int consequenceMax = 0; for(int i=0; i<10; i++){ int indexFound = foundLetter(unique, sizeU, letters[i]); if(indexFound != -1){ countU[indexFound]++; } else{ //insert it if not found unique[uniqueIndex] = letters[i]; countU[uniqueIndex]++; uniqueIndex++;
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Spring '17
  • Void type, Carriage return, int foundLetter

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture