The reason why you do not understand what the author is asking is because the question is based on SPECIFICALLY pure basic mathematical speech (Was hard for me to understand "math" word questions too). Change the program so that it writes out "the numbers are almost equal" after writing out which is the larger and the smaller if the two numbers differ by less than 1.0/100." In case any more students do the same, here's what I've come up with using 1.0 / 100 as the literal 0.01: #include "././std_lib_facilities.h"ĭouble lower(double int1, double int2) //function to calculate the smallest of two doublesĭouble upper(double int1, double int2) //function to calculate the largest of two doublesĬout << "The smaller value is: " << smallest << "\n" Ĭout << "The larger value is: " << largest << "\n" Ĭout << "The numbers are almost equal.\n" īy this point in the book you too should have already covered functions and can utilise them here to keep your main function tidy. Thank you for taking the time to read this.Įven though it's an old thread I've come across it whilst working through the the same book. Here is my code so far: #include "std_lib_facilities.h"Ĭout << "The smaller of the two numbers is: " << v2 << "\n" Ĭout << "The smaller of the two numbers is: " << v1 << "\n" Second, how do I determine "if the two numbers differ by less than 1.0/100"? (The more simple the solution the better.) Does that mean if the two numbers are within 100 numbers of each other? Change the program so that it writes out "the numbers are almost equal" after writing out which is the larger and the smaller if the two numbers differ by less than 1.0/100.įirst, I do not understand what "if the two numbers differ by less than 1.0/100." means. Exit the program when a terminating '|' is entered.Ĭhange the program to write out "the smaller value is:" followed by the smaller of the numbers and the "larger value is:" followed by the larger value.Īugment the program so that it writes the line "the numbers are equal" (only) if they are equal.Ĭhange the program so that it uses doubles instead of ints.ĥ. Write a program that consists of a while-loop that (each time around the loop) reads in two ints and then prints them. I am working from Bjarne Stroustrup's book "Programming Principles and Practice Using C 2nd Edition" and am on a Drill at the end of chapter 4.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |