Stay Tuned!

Subscribe to our newsletter to get our newest articles instantly!

C++ Programming

Write a Function that Passes two Temperature by Reference

Temperature by Reference

Write a Function that Passes two Temperature by Reference and Saves the Larger of the Two Number to Hundred by Using Return by Reference.

Source Code

#include<iostream.h>

#include<conio.h>

 float t1,t2;

void main()

{

  float &itemp(float &,float&);

 cout<<"Enter 1 temperature:"<<endl;

 cin>>t1;

 cout<<"Enter 2 temperature:"<<endl;

 cin>>t2;

 if(t1==t2)

 cout<<"Equal"<<endl;

 else

 {itemp(t1,t2)=100;

 if(t1==100)

 cout<<"Temperature 1is graeter"<<endl;

 else

 cout<<"Temperature 2 is larger"<<endl;

 }

  getch();

 }




float &itemp(float &a,float &b)

{

if(a>b)

return a;

else

return b;

}
Avatar

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

program to find leap year
C++ Programming

C++ Program to Find Leap Year by Using Function

  • March 3, 2016
Write a program to find if the inputted year is a leap year or not by using the concept of