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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -