why is their an error

–5 votes
asked May 5 by Ivana Ogunlaja (610 points)

#include <iostream>
#include <string>

using namespace std;

int main ()
{
    cout << "Hello I am zyxo 64.\n";
    cout << "I am a chatbot";
    string name;
    cout << "What is your name";
    cin >> name;
    cout << "Hello " << name << "Nice to meet you";
    int age;
    cout << "Can you guess how old I am";
    cin >> age;
    
    if(age== 64){
        cout << "You are correct";
    }else{
        cout << "You are wrong I am 64";
    }
    
    int year;
    cout << "I am not very good at dates.\n";
    cout << "What year is it";
    cin >> year;
    cout << "That sound about right thank you"
    return 0;
    }   
    
    
}    

output: 

main.cpp: In function ‘int main()’:
main.cpp:29:5: error: expected ‘;’ before ‘return’
     return 0;
     ^~~~~~
main.cpp: At global scope:
main.cpp:33:1: error: expected declaration before ‘}’ token
 }
 ^

5 Answers

+2 votes
answered May 5 by aalshabaan (490 points)
selected May 6 by Ivana Ogunlaja
 
Best answer
Il literally says it in the output error, a ';' is missing before "return"

Add a semicolon after ...thank you"
commented May 6 by Ivana Ogunlaja (610 points)
oh yeah it does thanks
0 votes
answered May 5 by Eric VanSchaick (200 points)
you need a ; at the end of     cout << "That sound about right thank you";

and remove the } right after return 0; you have an extra one

correction:
    cout << "I am not very good at dates.\n";
    cout << "What year is it";
    cin >> year;
    cout << "That sound about right thank you";
    return 0;  
}
0 votes
answered May 5 by Aman2241 (140 points)

    cout << "That sound about right thank you";  (there will be semi column at last)
   

   and at last there sill be only one curly braces closed not two.

0 votes
answered May 5 by Pallala Sreeja (140 points)
missing semicolon before return 0,check it once.
+1 vote
answered May 6 by LiOS (5,120 points)
#include <iostream>
#include <string>

using namespace std;

int main ()
{
    cout << "Hello I am zyxo 64.\n";
    cout << "I am a chatbot";
    string name;
    cout << "What is your name";
    cin >> name;
    cout << "Hello " << name << "Nice to meet you";
    int age;
    cout << "Can you guess how old I am";
    cin >> age;
    
    if(age== 64){
        cout << "You are correct";
    }else{
        cout << "You are wrong I am 64";
    }
    
    int year;
    cout << "I am not very good at dates.\n";
    cout << "What year is it";
    cin >> year;
    cout << "That sound about right thank you";
    return 0;
    }  
    
}
commented May 6 by Ivana Ogunlaja (610 points)
thanks it works now
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...