I want to make a program that reads 5 numbers and tell me the largest number, the smallest number and the sum of the numbers, in C ++ using the for
loop.
I tried and did so:
#include <iostream>
using namespace std;
int main()
{
int n, i, h, l, s;
cout<<"Digite 5 numeros:\n";
for (i=0; i<5; i++)
{
cin>>n;
s+=n;
if (n>l)
{
n=h;
}
else
{
n=l;
}
}
cout<<"O maior numero e "<<h<<", o menor e "<<l<<" e a soma e "<<s<<".\n";
return 0;
}