write a program to enter ten numbers and display the highest using array.

Recommended Answers

All 2 Replies

I think you are confused. First you write the program and then you post it with any problems you are having.

#include<iostream>
using namespace std;

int main(){
    float arr[10];
cout<<"please enter 10 numbers"<<endl;

for(int i=0; i<10; i++){
    cin>>arr[i];
}

for(int i=0; i<9; i++){
    int small = i;
    for(int j=i+1; j<10; j++){
        if(arr[j]<arr[small])
       small = j;
        }
    if(arr[i]!=arr[small])
    swap(arr[i],arr[small]);
    }

cout<<"\nThe greatest number is "<<arr[9]<<endl;
return 0;}

make sure you understand the code...that's a good programmer's habit

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.