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 (562)
 C++ General interview questions  C++ General Interview Questions (459)
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 ?    79 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 a virtual class? Cap-Gemini 5
1. Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list) Nagarro 1
what are abstract classes and how they impliment , with example   2
What is the difference between C++ and java?   4
program in c++ that can either 2 integers or 2 floating point numbers and output the smallest number Anna-University 1
Child cObj = new Parent() Wahts the output ? TCS 8
What is the use of fflush(stdin) in c++? HCL 4
what is static?   3
Definition of Object Oriented Programming in single line? TCS 33
explain the concepts of oops?   1
Pls...could any one tell me that whether we can access the public data memeber of a class from another class with in the same program. Awaiting for your response Thanku   4
How compiler selects(internally) required overridden function in inheritance? CSC 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