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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -