Computer Science, asked by diyab0416, 1 year ago

Write a program to find biggest of 10 given numbers using an efficient way(plzzz tell me itssss really urgent)


Anonymous: C++ or Java
diyab0416: java
diyab0416: n without using return becoz ur teacher had given this prog n he did not taught the use of return yet
Anonymous: What you mean by return ?
diyab0416: u using return n dong programs?
diyab0416: doing*
Anonymous: So is the answer that I gave below ok?
diyab0416: yup it is kk but i have done by another method tysm plzzz may u help me in one question that is multiples of 5 using do while

Answers

Answered by Anonymous
0

#include <iostream>

using namespace std;

int main()

{

int i, n=10;

float arr[11];

for(i = 0; i < n; ++i)

{

cout << "Enter Number " << i + 1 << " : ";

cin >> arr[i];

}

for(i = 1;i < n; ++i)

{

if(arr[0] < arr[i])

arr[0] = arr[i];

}

cout << "Largest element = " << arr[0];

return 0;

}

Hope it helps


diyab0416: java language n without using return plzzzzzzzzzzz
Anonymous: import java.util.Scanner;
public class Largest_Number
{
public static void main(String[] args)
{
int n, max;
Scanner s = new Scanner(System.in);
System.out.print("Enter number of elements in the array:");
n = s.nextInt();
int a[] = new int[n];
System.out.println("Enter elements of array:");
for(int i = 0; i < n; i++)
{
a[i] = s.nextInt();
}
max = a[0];
for(int i = 0; i < n; i++)
{
if(max < a[i])
{
max = a[i];
}
}
System.out.println("Maximum value:"+max);
}
}
Anonymous: Plz do hit the thanks button.
Anonymous: That answer was wrong
Anonymous: This is the correct one
Anonymous: import java.util.Scanner;
public class Largest_Number
{
public static void main(String[] args)
{
int max, n=10;
int a[11];
System.out.println("Enter elements of array:");
for(int i = 0; i < n; i++)
{
a[i] = s.nextInt();
}
max = a[0];
for(int i = 0; i < n; i++)
{
if(max < a[i])
{
max = a[i];
}
}
System.out.println("Maximum value:"+max);
}
}
Similar questions