how to find out the maximum number out of the three inputs.
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
//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 |
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 |
write a program that can LOCATE and INSERT elements in array using c++ programming languages.
An array of size 5X5 is given to us. The elements from 1 to 25 are to be inserted in the array, such that starting from a particular position for an element i, the next element i+1can be inserted only at the mentioned positions (u,v), and if these all positions are occupied then it returns giving a count of how many positions have been occupied in the array: (u,v) = (x+/-3 , y) (u,v) = (x , y+/-3) (u,v) = (x+/-2 , y+/-2). Example: if the starting element is 1 with the given positions (1,2), then next element 2 can be placed at any one of the positions marked with *. _ _ _ _ _ 1 _ _ _ * _ _ _ _ _ _ _ * _ _ * _ _ _ _
what is the difference between int &r and int& r
Write an algorithm that receives a string and reverses it.
Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37
swap prog
Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and with complexity T(n) is at most about (1.5)n comparisons.
10 Answers ABC, College School Exams Tests, ITC Infotech, Kyambogo University, Qatar University,
write a program that calculate the volume of cylinder after user enters radius and height and show the algorithm used
1 Answers Jomo Kenyatta University,
What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }
3 Answers CTS, IBM, Infosys, Qatar University,
U hv to enter a range from a and b and search hw many no. of times a pattern n. occurs between the range a and b. Eg :i/p:enter range :0 100 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 0 to 100:1 Eg :i/p:enter range :100 1000 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 100 to 1000: (in this 13,113,131,132,133…139,213,313,…913 all these will be counted)
1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.
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?