Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a c++ program to find maximum of two numbers using
inline functions.

Answer Posted / ada

#include <iostream>
using namespace std;

template<typename T>
inline T& max(T& x, T& y)
{
return x>y ? x:y;
}

int main()
{
char bx = 'a', by = 'b';
int ix = 1, iy = 2;
float fx = 1.5, fy = 2.5;
double dx = 2.5, dy = 1.5;
cout<<"char max:"<<max(bx, by)<<endl;
cout<<"int max:"<<max(ix, iy)<<endl;
cout<<"float max:"<<max(fx, fy)<<endl;
cout<<"double max:"<<max(dx, dy)<<endl;
return 0;
}

Is This Answer Correct ?    39 Yes 33 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is oops in simple words?

1038


What is the problem with multiple inheritance?

1105


Why oops is important?

1045


Explain virtual inheritance?

1140


Write a c++ program to display pass and fail for three student using static member function

3337


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

2091


Write a program to sort the number with different sorts in one program ??

2331


What is object in oops?

1026


What are the data types in oop?

1051


why reinterpret cast is considered dangerous?

2339


Why do pointers exist?

1050


What are the two different types of polymorphism?

1093


What is class in oop with example?

1051


Why we use classes in oop?

981


How do you define social class?

1019