c++ - Finding the difference between two temperature -
i have function supposed find difference between 2 temp's. first off print out celsius , approx fahrenheit , find , print difference between them. problem happens when run program output difference 58 everything.
where should print out this:
c----af----diff 1----32----31 2----34----32 etc.
my code:
void caldiff(int& cel, int& appfar, int diff){ while(cel!= 101){ diff = appfar - cel; cout << diff << endl; cel++; appfar++; } }
- you need function convert celsius fahrenheit.
- you don't want change
cel,appfar, remove reference&.
int cel2far(int cel) { // convert cel far , return approx. far } void caldiff(int cel, int appfar, int diff) { while(cel!= 101){ diff = appfar - cel; cout << diff << endl; cel++; appfar = cel2far(cel); } }
Comments
Post a Comment