how to find the maximum of 10 numbers ?
Answers were Sorted based on User's Feedback
Answer / amrutha
int a[]=new int[10];
int max=a[0];
for(int i=0; i<10; i++)
{
if(a[i]>max)
{
max=a[i];
}
}
System.out.println("Maximum of 10 :" + max);
Is This Answer Correct ? | 21 Yes | 8 No |
Answer / raj
int a[10],max=0;
cout<<"enter 10 numbers";
for(int i=0;i<10;i++)
{
cin>>a[i];
if(a[i]>max)
max=a[i];
}
cout<<"the maximum of entered 10 is"<<max;
Is This Answer Correct ? | 9 Yes | 6 No |
Answer / namitha
#include<iostream.h>
main()
{
int a[10],n;
cout<<"enter ten numbers:\n";
for(int i=0;i<10;i++)
{
cin>>a[i];
}
int max=a[0];
for(i=0;i<10;i++)
{
if(a[i]>max)
max=a[i];
}
cout<<"the maximum number is:"<<max<<endl;
}
Is This Answer Correct ? | 4 Yes | 1 No |
Answer / ahmed.aboelella
/**
As there is no need to save in array
Also we have to init max with first value to get max in case
user entered negative values
*/
#include "iostream"
using namespace std;
void main()
{
cout<<"Enter 10 numbers: ";
int i, temp, max;
//Enter first number to init max
cin>>max;
for(i = 0 ; i < 9; i ++)
{
cout<<"Enter Number: ";
cin>>temp;
max = temp > max ? temp : max;
}
cout<<"Max Number is "<<max<<endl;
}
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / prits
#include <iostream>
using namespace std;
void main()
{
int max = 0;
int arr[10];
cout<<"Enter 10 numbers"<<endl;
for(int i = 0; i<=10; i++)
{
cin>>arr[i];
}
for(int i = 0; i<=10; i++)
{
if(arr[i]>max)
max =arr[i];
}
cout<<"Maximun of the 10 numbers is "<<max<<endl;
}
Is This Answer Correct ? | 4 Yes | 3 No |
what is data encapsulation in C++?
What do you understand by zombie objects in c++?
How do you remove an element from a set in c++?
Why should you learn c++?
Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?
What is the purpose of templates in c++?
Why do we need templates?
What are c++ tokens?
What is your strongest programming language (Java, ASP, C, C++, VB, HTML,C#, etc.)?
24 Answers Infosys, Microsoft, TCS,
What C++ libraries are you proficient with?
What is a virtual destructor?
Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].