ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C++ >> OOPS
 
 


 

 
 STL interview questions  STL Interview Questions (91)
 OOPS interview questions  OOPS Interview Questions (558)
 C++ General interview questions  C++ General Interview Questions (458)
Question
write a c++ program to find maximum of two numbers using 
inline functions.
 Question Submitted By :: OOPS
I also faced this Question!!     Answer Posted By  
 
Answer
# 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 ?    77 Yes 30 No
Manjunathtek
 
Answer
# 2
dont no 
Is This Answer Correct ?    1 Yes 0 No
Kani
 
 
 
Answer
# 3
#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 ?    27 Yes 27 No
Ada
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
What is virtual class and friend class? Intel 5
Conversion from a basic type to a class type may be achieved using______________ HCL 5
what is difference between String s=new String("vali"); String s="vali"   1
Describe what an Interface is and how it?s different from a Class. Spinsys 7
what are abstract classes and how they impliment , with example   2
What is R T T I ? Ness-Technologies 6
What is the difference between const int *ptr and int const *ptr???   2
What is an orthogonal base class?   1
What is the difference between pass by value,pass by pointer,pass by reference in the catch block in the exception handling in c++ TCS 1
What is a friend function & its advantage? TCS 2
all about pointers   2
How to overload postfix operator in c++ Mphasis 1
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com