Hello I am reather new in c++ and I try to solve some exercises but i got blocked. Can anyone help me with this?
The program should read in values until a negative value is read in. It should determine the largest value that was read in and display that value once the loop stops.
This program involves indefinite iteration using a sentential controlled loop. The sentential value is any negative integer. The fact that negative integers are sententials should help you determine how to initialize the variable that contains the largest integer.
I wrote this code but it gives me only the result 0:
#include<iostream>
using namespace std;
int main ()
{
int numar, biggest =0;
cout<<"insert an integer ";
while( numar > 0)
cin>>numar;
numar=biggest;
if(numar<biggest)
{
numar = biggest;
}
cout<<biggest;
system("pause");
return 0;
}
and just don'tknow what is wrong