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

Answers were Sorted based on User's Feedback



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

Answer / manjunathtek

#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

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

Answer / kani

dont no

Is This Answer Correct ?    15 Yes 4 No

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

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

Post New Answer

More OOPS Interview Questions

What is the concept of object oriented program?

6 Answers  


what is runtime polymorphism? For the 5 marks.

3 Answers  


What is difference between #define and const?

3 Answers   emc2,


Can we have inheritance without polymorphism?

0 Answers  


What is encapsulation with example?

0 Answers  






1. Define a class.

6 Answers  


The type of variable a pointer points to must be the part of pointer's definition so that:

1 Answers   Infosys,


advantage and disadvantage in c++>>oops and what are the questions ask for interview in c++>>oops. could you tell me or reply me

0 Answers  


What is abstract class in oop?

0 Answers  


What is Method overloading?

5 Answers  


INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

0 Answers  


Why is there no multiple inheritance?

0 Answers  


Categories