Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function named change() that has an integer parameter and six integer re

ID: 674808 • Letter: W

Question

Write a function named change() that has an integer parameter and six integer reference parameters named hundreds, fifties, twenties, tens, fives, and ones. The function is to consider the passed integer value as a dollar amount and convert the value into the fewest number of equivalent bills. Using the reference parameters, the function should alter the arguments in the calling function. Include the function in a working program. Make sure your function is called from main () and returns a value to main () correctly. Have main () use a cout statement to display the returned value. Test the function by passing various data to it and verifying the returned value. Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program must contain a function with one of its parameters as a string variable and return the number of times each lowercase vowel appears in it. Also write a program to test your function. (Note that if str is a variable of type string, then str. at (i) returns the character at the ith position. The position of the first character is 0. Also, str. length () returns the length of the str, that is, the number of characters in str.)

Explanation / Answer

8. CPP function change()

#include <iostream>
#define exchRate 60
using namespace std;

void change(int amtDollar, int *hundreds, int *fifties, int *twenties, int *tens, int *fives, int *ones)
{
int amtInr = amtDollar * exchRate;
*hundreds = amtInr/100;
amtInr = amtInr%100;
*fifties = amtInr/50;
amtInr = amtInr%50;
*twenties = amtInr/20;
amtInr = amtInr%20;
*tens = amtInr/10;
amtInr = amtInr%10;
*fives = amtInr/5;
amtInr = amtInr%5;
*ones = amtInr;
}


int main()
{
int amtDollar, hu, fif, tw, te, fiv, on;
cin >> amtDollar;
change(amtDollar, &hu, &fif, &tw, &te, &fiv, &on);
cout<< "Hundred : "<< hu << "| Fifties : "<< fif << "| Twenties :"<< tw << "|Tens : "<< te << "| Ones :"<<on <<" ";

return 0;
}


9. CPP program to count LowerCase Vowels in String

#include<iostream>
#include<string>
using namespace std;

int main()
{
string str;
int len,i;

/* Assuming a,e,i,o,u corresponding to index 0,1,2,3,4 of the array */
int arr[5]={0,0,0,0,0};

cin >> str;
len = str.length();

for(i=0; i<len; i++)
{
if(str.at(i) == 'a')arr[0]++;
else if(str.at(i) == 'e')arr[1]++;
else if(str.at(i) == 'i')arr[2]++;
else if(str.at(i) == 'o')arr[3]++;
else if(str.at(i) == 'u')arr[4]++;
}

cout <<" a : "<<arr[0];
cout <<" e : "<<arr[1];
cout <<" i : "<<arr[2];
cout <<" o : "<<arr[3];
cout <<" u : "<<arr[4];

return 0;
}

Please let me know in case you have any queries

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote