Your program reads float numbers and during the reading every time the (absolute) biggest number
is printed. To do so, use a function Find_max() that from two numbers returns the biggest.
The program ends after entering the number 0.
draw PSD for the program before writing program.
1
Expert's answer
2011-10-13T08:15:34-0400
#include <cstdlib> #include <iostream>
using namespace std; float a,b,Max; float Find_max(float a,float b) { if (a>=b) return Max=a; else return Max=b; } int main(int argc, char *argv[]) { cout<<"Enter first numder a = "; cin>>a; cout<<"Enter second numder b = "; cin>>b; if (a==b) cout<<"a = b = "<<a<<endl; else if (a==0 || b==0) exit(); else { & Find_max(a,b); & cout<<"Max = "<<Max<<endl; } system("PAUSE"); return EXIT_SUCCESS; }
Comments
Leave a comment