how to find out the maximum number out of the three inputs.

Answers were Sorted based on User's Feedback



how to find out the maximum number out of the three inputs...

Answer / hsandeep007

Hi Angads,

here is the code that need to implement.
I used java..

class largeNum{
public static void main(String args[])
{
int i,j,k;

i = Inter.parseInt(args[0]);
j = Inter.parseInt(args[1]);
k = Inter.parseInt(args[2]);



if (i>j && i>k)
{
system.out.print("i is max" + i);
}
else if(j>i && j>k)
{
system.out.print("j is max" + j);
}
else if(k>i && k>j)
{
system.out.print("k is max" + k);
}
}
}

Is This Answer Correct ?    32 Yes 13 No

how to find out the maximum number out of the three inputs...

Answer / dapumptu

If the inputs are a, b, and c,

max = a;
if (b > max) max = b;
if (c > max) max = c;

now max will contain the largest of the three.

Is This Answer Correct ?    17 Yes 6 No

how to find out the maximum number out of the three inputs...

Answer / ceeemor

#include<iostream>
using namespace std;
int main() {

int num[3];

cout << " Input 3 integers : ";
for (int i =0; i <3; i++) {
cin >> num[i];
}

sort(num, num+3);

cout << " The largest num in the given input s : " << num
[2] << endl;

return 0;
}

Is This Answer Correct ?    14 Yes 5 No

how to find out the maximum number out of the three inputs...

Answer / suganthi

27

Is This Answer Correct ?    18 Yes 12 No

how to find out the maximum number out of the three inputs...

Answer / pavan mustyala

//Single statement code using ternary operator

int max(int a, int b, int c)
{
return (((a > b) ? a : b) > c) ? ((a > b) ? a : b) : c;
}

Is This Answer Correct ?    14 Yes 8 No

how to find out the maximum number out of the three inputs...

Answer / leonard a wilson iii

//Done in c#
//using x,y,z to test the outcome as maximium

double x=45,y=25,z=2,maximium=0;
if (z != Math.Max(x,y))
maximium=Math.Max(x,z);
Console.WriteLine("x={0},y={1},z={2} the max
is{3}", x, y, z, maximium);


//Leonard A Wilson III

Is This Answer Correct ?    6 Yes 8 No

Post New Answer

More C++ Code Interview Questions

Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.

3 Answers   TCS, Vimukti Technologies, Wipro,


what is the diffrence between ++x , x++ pleaaaaase ???

7 Answers  


3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...

0 Answers  


what is the difference between int &r and int& r

3 Answers  


write a c program, using for loop, that accepts and odds two numbers. The output must be the sum and the addens. This should be repeated 5 times while the first number is decremented by one and the second number is incremented by 1.

2 Answers   IBM, Infosys,






a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.. ""EXAMPLE"" enter how many numbers to be inputted: 5 12 14 11 09 30 what number to search: 11 11 IS FOUND IN LOCATION 3 PLZZZ.. ELP ME...

3 Answers  


using friend function find the maximum number from given two numbers from two different classes.write all necessary functions and constructor for the classes.

1 Answers   TCS,


write a proram using exceptional handling create a error & display the message "THERE IS AN ERROR?... PLEASE RECTIFY"?

1 Answers  


what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }

0 Answers  


Write a program that print in screen a tree with its height taken from user by entering number of 4 digits and find the odd numbers then calculate the sum of odd numbers so he get the height of tree?

0 Answers  


Write a program to enter 10 number of integer entries into an array n and then odds up all the odd entries. the program then displays the result. plssss answer assss fast asss u can...

1 Answers  


Subsets Write an algorithm that prints out all the subsets of 3 elements of a set of n elements. The elements of the set are stored in a list that is the input to the algorithm. (Since it is a set, you may assume all elements in the list are distinct.)

1 Answers   CSC, Qatar University,


Categories