jeudi 5 août 2021

Unchange ouput despite the variables

I'm trying to create simple C++ program in VS code, this is the original code:

# include <iostream>

using namespace std;

int main()
{

    cout <<"there was once a man named John" << endl;
    cout <<"he is 35 years old"<< endl;
    cout <<"but didn't like being 35"<< endl;

    return 0 ;

}

the ouput is:

there was once a man named John
he is 35 years old
but didn't like being 35

I've tried to upgrade the program by adding 2 variables called character_name and character_age.

# include <iostream>

using namespace std;

int main()
{
    string character_name = "Jay";
    int character_age;
    character_age = 30;
    cout <<"there was once a man named "<< character_name << endl;
    cout <<"he is"<< character_age <<"years old"<< endl;
    cout <<"but didn't like being 30"<< endl;

    return 0 ;

}

The output is supposed to be:

there was once a man named Jay
he is 30 years old
but didn't like being 30

But somehow the output is still the same the previous one, I've intentionally created many syntax errors and the output is still unchanged. How can I fix this ?

Aucun commentaire:

Enregistrer un commentaire