Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why is their an error

–4 votes
asked May 5, 2020 by Ivana Ogunlaja (640 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, 2020 by aalshabaan (490 points)
selected May 6, 2020 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, 2020 by Ivana Ogunlaja (640 points)
oh yeah it does thanks
0 votes
answered May 5, 2020 by Eric VanSchaick (240 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, 2020 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, 2020 by Pallala Sreeja (140 points)
missing semicolon before return 0,check it once.
+1 vote
answered May 6, 2020 by LiOS (6,420 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, 2020 by Ivana Ogunlaja (640 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.
...