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 |
If a=5, b=6, c=7, b+=a%c*2. What is the final value of b?
i hav very low percentage in 12th n BSCwhich is around 50.......coz it was just imposed on me 2 b a science graduate,nw m doin MCA n hav aggregate 74% ....what shud i answer if company's HR ask me about dis much low previous percentage??????
What is multilevel inheritance?
what is the difference between inter class and abstract class...?
what are the disadvantages of C++?
25 Answers ATS, Infosys, UNI, Wipro,
create a c++ program that will accepts 9 inputs using 3 by 3 array.
What does I oop mean?
what is different between oops and c++
Difference between new operator and operator new
what is difference between String s=new String("vali"); String s="vali"
In multiple inheritance , to create sub class object , is there need to create objects for its superclasses??? in java and c++ both. Actually i have some information that is , all available members from its superclasses , memory created in subclass obj , so no need to create object for its superclasses...??? Thanks in Advance
Can destructor be overloaded?