Question: 1 . Write a C + + program that does the following: a . Create a C + + file with the name problem 3

1. Write a C++ program that does the following:
a. Create a C++ file with the name problem3.cpp.
b. Write the function sumRatioswhich computes the sum of the ratios of the corresponding digits of its two positive integer parameters. Assume both parameters have the same number of non-zero digits.
c. For example, if the two parameters are 132 and 568, then sumRatios computes and returns 1/5+3/6+2/8 which equals 0.95.
d. Type in the following main function into your C++ program file:
int main()
{
cout << sumRatios(132,568)<< endl; // prints 0.95
cout << sumRatios(123,456)<< endl; // prints 1.15
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!