Answer to Question #213111 in C++ for Aadi

Question #213111

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.


1
Expert's answer
2021-07-03T04:49:16-0400

//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;	
	}
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS