cout not printing an int by itself

14 Views Asked by At

As the title reads, cout will not print an int by itself. If I print a string literal before it, the int will print. See code and output below:

//********This prints nothing***********
#include <iostream>

using namespace std;

int main() {
    int age{30};
    cout << age << endl;

    return 0;
}
//*********This prints nothing**********


//********This prints 'You are 30'*********
#include <iostream>

using namespace std;

int main() {

    int age{30};
    cout << "You are " << age << endl;

    return 0;
}
//**********This prints 'You are 30'*********
0

There are 0 best solutions below