Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called sumConsonants that will take as arguments two upper case letters. Your function should return a sum of all the ascii values

Write a function called sumConsonants that will take as arguments two upper case letters. Your function should return a sum of all the ascii values of the consonants between the starting character and the ending character. Your main function should pass two values to the function and output the sum of all the consonant character values including the first and the last.

Required:

Your function must allow for either argument to be larger. For instance, passing A, C should yield the same as passing C, A.

You must also insure that the arguments to this function are upper case characters. If either argument is not you should return a -1 from the function;

It is best to use the isupper function see below.

You are allowed to use one decision (or two conditional statements) before the for loop to set the order of the characters.

You are allowed to use one decision before the for loop to determine the case of the characters.

You are allowed to use one decision inside the for loop to determine if the character is a vowel or consonant.

The order of the arguments must be taken care of prior to the beginning of the loop.

What not to do

Using any of the following will drop your grade for this assignment by 70%

global variables

cin in sumConsonants function

cout in sumConsonants function

goto statements

Note:

A char really is nothing more than an integer value. It is a short int value in between 0 and 255. What is different is how it is treated. Since you want to add a char to an int you will want to cast it:

char c = 'A';

int x = static_cast(c);

x now has the value of 65

isupper function

 /* isupper example */ 
 #include  
 #include  int main() { int i=0; char str[]= "Test String. "; char c; while (str[i]) { c=str[i]; if (isupper(c)) c=tolower(c); cout << c << endl; i++; } return 0; }student submitted image, transcription available below 
Your program should look like the following CAWINDOWS system32\cmd.exe Enter two upper case chars The sum of the consonants betwee the two chars is 201 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago

Question

Have issues been prioritized?

Answered: 1 week ago

Question

Has the priority order been provided by someone else?

Answered: 1 week ago