Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6065413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:23:15+00:00 2026-05-23T09:23:15+00:00

The error I’m getting is error: expected ‘ ; ‘ before ‘ { ‘

  • 0

The error I’m getting is error: expected ' ; ' before ' { ' token

I tried fixing the code by adding ; after if (thisisanumber==5) as well as after else (thisisanumber!=5). While this solves the first error it creates another error that says error: ' else ' without a previous ' if '. I’d really love to know what error I’ve made in writing the code, thanks.

Here is my code:

#include <iostream>

using namespace std;

int main()
{
    int thisisanumber;

    cout<<"Whats the Password?: ";
    cin>> thisisanumber;
    cin.ignore();
    if (thisisanumber==5) {
        cout<<"You've discovered the password! Wow, you're a genious you should be proud./n";
        }
    else (thisisanumber!=5) {
        cout<<"You've failed in knowing the password and therefore cannot enter, leave and do not come back. Goodbye!/n";
        }
    cin.get();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:23:16+00:00Added an answer on May 23, 2026 at 9:23 am

    You don’t need another condition as there are only two cases – just use else { ... } and it will catch all cases in which thisisanumber==5 is false.

    The structure of an if statement is:

    if (condition) { ... }
    
    else if (another condition) { ... }
    // ... more conditions
    
    else { ... all cases in which no previous condition matched end up here  ... } 
    

    … but the else if and else parts are always optional.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Error from firebug: missing ) after condition [Break on this error] else if (($(this).parent...nt().hasClass('plaing')==true)
error msg: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. code: strSQL =
Error I tried this page to run on local, it is running perfectly fine
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: N O) I've tried
Error console: unterminated string literal $html='<li><div class=above>'+$question_number+ 'Question Title</div> The JQuery code is: $html='<li><div
Error im getting: An unhandled exception of type 'System.StackOverflowException' occurred in System.Management.dll My callstack:
Error: uncaught exception: [Exception... Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage] nsresult: 0x80040111 (NS_ERROR_NOT_AVAILABLE)
Error: Type mismatch: cannot convert from Set<ConstraintViolation<capture#1-of ?>> to Set<ConstraintViolation<Class<?>>> My code: public class
Error message: fatal: git checkout: updating paths is incompatible with switching branches/forcing How to
Error loading script occurs under FireFox 3 if I quickly click different links on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.