Error w/declaration on else statement (C++) -


#include <iostream>  using namespace std;  // range of numbers, handles input in first number smaller second.  int main() {     int max = 10;     int min = 0;     while(cin >> min)     {         if(min<max)         {             ++min;             cout << "the number inputted in range: " << min << endl;         else         {             cout << "the number inputted not in range: " << max << endl;         }     } } // end of if. } 

what's going on? why isn't working? i'm new stack tried posting this, er help?

you should end if before start else part :

int main() { int max = 10; int min = 0; while(cin >> min){    if(min<max){      ++min;         //dont understand why do !      cout << "the number inputted in range: " << min << endl;      } // end of if.    else{    cout << "the number inputted not in range: " << max << endl;     }    }     } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -