program

hi everbody I have a problem if I have program like this
in the end i need to ask if you want continue? yes no if yes then continie program,
I just dont understand that return principle

#include <iostream>
using namespace std;
int main () {
int n=0;
int flag=0;
int mas[2]={0,0};
do{
cin >> n;
if(flag ==0){
mas[0] = n;
}
if(flag == 1){
if(mas[0]>n){
mas[1]=mas[0];
mas[0]=n;
}
else mas[1]=n;
}

if(n==0){ ;
break;}
if(n<mas[0] && flag>1){
if(mas[0]<mas[1]){
mas[1]=mas[0];
mas[0]=n;
}
else mas[0]=n;
}
else if(n<mas[1] && flag>1){
mas[1]=n;
}
flag++;

}while(n!=0);
if (mas[0]==mas[1]) {
cout << "Sie abi skaitli ir vienadi" ; } else
cout << mas[1];

return 0;
}
Last edited on
..........
1
2
3
4
5
6
7
8
9
10
11
do {

    //...program...

    char answer;
    cout << "Again? ";
    cin >> answer;
    if( answer != 'y' && answer != 'Y' )
        break;

} while(true)
Your variable names and commenting are alot to be desired.
what exactly are you trying to do?
Topic archived. No new replies allowed.