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 (93)
 OOPS interview questions  OOPS Interview Questions (563)
 C++ General interview questions  C++ General Interview Questions (461)
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 ?    82 Yes 31 No
Manjunathtek
 
Answer
# 2
dont no 
Is This Answer Correct ?    4 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 ?    29 Yes 27 No
Ada
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
when my application exe is running nad i don't want to create another exe what should i do HCL 2
Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3   2
what is the function of 'this' operator ? Wipro 7
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.   1
What is function overloading?,describe it with the example.   5
why the argument is passed by reference to a copy constructor?example?   2
monkey starts climbing up a tree 20ft tall,each hour ,it hops 3ft and slips back by 2ft .how much time it wil tak to reach top of the tree? IonIdea 12
What are virtual functions?   2
can inline function declare in private part of class?   1
Have you ever interfaced with a database? IBM 2
What do you mean by binding of data and functions?   3
What is the difference between the c++ & java?   2
 
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