write a c++ program to find maximum of two numbers using
inline functions.
Answers were Sorted based on User's Feedback
#include<iostream>
using namespace std;
int main()
{
int c;
c=max(5,4); //will display 5
cout<<c<<endl;
return 0;
}
inline int max(int a, int b)
{
return (a>b)? a:b;
}
| Is This Answer Correct ? | 140 Yes | 52 No |
Answer / 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 |
Is oop better than procedural?
• What are the desirable attributes for memory managment?
What is friend function?
Write a program to sort the number with different sorts in one program ??
should we use linear search or binary search if elements are placed in random order or mixed?in both cases? i need a little bit detail ans?thnks
what is Class in oops with example?
what is object oriented programming and procedure oriented programming?
to find out the minimum of two integer number of two different classes using friend function
write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
Prepare me a program for the animation of train
wht is ditch