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

#include<stdio.h> #include<conio.h> void main() { char str[10]; int,a,x,sw=0; clrscr(); printf("Enter a string:"); gets(str); for(x=0;x<=a;a++); for(x=0;x<=a;x++) { if(str[x]==str[a-1-x]) { sw=1; } else sw=0; } if(sw==10 printf("The entered string is palindrome:"); else printf("The entered string is not a palindrome:); } getch(); } wht would be the explanation with this written code???

2 Answers  


How to Split Strings with Regex in Managed C++ Applications?

0 Answers   Microsoft,


Given 1 to n distinct random number of which n+1th element was duplicated. How do find the duplicate element and explain the time complexity of the algorithm.

0 Answers   Microsoft, NetApp,


Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?

0 Answers   ASD Lab, Qatar University, UNV,


write a program to calculate the radius for a quadratic equation use modular programming(function abitraction)hint use quadratic function

1 Answers   ICAN, Jomo Kenyatta University,






Show by induction that 2n > n2, for all n > 4.

2 Answers   Karvy, Qatar University,


write a program that can locate elements in array.

1 Answers  


Where now stands that small knot of villages known as the Endians, a mighty forest once stood. Indeed, legand has it that you could have stoodon the edge of the wood and seen it stretch out for miles, were it not for the trees getting in the way. In one section of the forest, the trees stood in a row and were of hight from 1 to n, each hight occurring once and once only. A tree was only visible if there were no higher trees before it in the row. For example, if the heights were 324165, the only visible trees would have been those of height 3,4 & 6. Write a Program that takes an array of integers representing the heights of the trees in the row as input and prints the list of the visible trees.

2 Answers   ABC, Nagarro,


write a program that can LOCATE and INSERT elements in array using c++ programming languages.

0 Answers  


write a program that reads a series of strings and prints only those strings begging with letter "b"

0 Answers  


What will be the output- for(i=1;i<=3;i++) { printf("%d",i); continue; i++; }

5 Answers   Impetus,


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,


Categories