Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new

 Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS

 STL Interview Questions OOPS Interview Questions C++ General Interview Questions
Question
```write a c++ program to find maximum of two numbers using
inline functions.```
Question Submitted By :: Shephaliaishwarya
I also faced this Question!!     Rank Answer Posted By

Re: write a c++ program to find maximum of two numbers using inline functions.
# 1
#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 ? 73 Yes 27 No
Manjunathtek
[Teknoturf Info Services Pvt. Ltd]

Re: write a c++ program to find maximum of two numbers using inline functions.
# 2
#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 ? 25 Yes 26 No

Re: write a c++ program to find maximum of two numbers using inline functions.
# 3
dont no
 Is This Answer Correct ? 0 Yes 0 No
Kani

  Question Asked @ Answers Other OOPS Interview Questions what is the technical or oop name of object? 1 When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory?? Honeywell 13 How compiler selects(internally) required overridden function in inheritance? CSC 2 what is the difference between javap and jad utility Wipro 1 if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence? 1 What is friend function? Wipro 12 what is the difference between class and structure in C++? Aspire 9 When is it necessary to use member-wise initialization list in C++? Adobe 2 4. What do you mean by a prototype? Define analysis prototype 1 Describe the difference between a Thread and a Process? 10 Hi All, I am new to programming and want to know how can i write a code to take input of 2 numbers from user and swap it without using a temp variable? NIIT 2 what does exactly the linker do? 1 For more OOPS Interview Questions Click Here