Develop a program that uses a function called large_is_zero(). This function takes
two float arguments as pass by reference and then this function sets the large number to zero.
//A program to accept two double numbers and sets largest to zero
#include<iostream>
using namespace std;
double large_is_zero(double* num1,double* num2)
{
double c;
c=(*num1>*num2)?*num1:*num2;
return(c);
}
int main()
{
double num1,num2;
cout<<"Enter any two numbers of type double\n\n";
cin>>num1>>num2;
cout<<"Large of the two is "<<large_is_zero(&num1,&num2)<<"\n\n";
if(num1>num2)
{
num2=0.0;
cout<<large_is_zero(&num1,&num2)<<" is set to "<<num2;
}
else
{
num1=0.0;
cout<<large_is_zero(&num1,&num2)<<" is set to "<<num1;
}
}
Comments
Leave a comment