Putting a Space in cout output

Mar 14, 2018 at 1:42pm
cout << age << "is your age.\n";

I would like put a space between age & is your age in the obove example output:

Thanks,
Chester
Mar 14, 2018 at 2:17pm
Hello samtheman,

All you have to to is tell it to like:
1
2
cout << age << " is your age.\n";
//              ^ space here. 

or cout << age << ' ' << "is your age.\n";

Hope that helps,

Andy
Mar 14, 2018 at 2:23pm
@Handy Andy already answered this question. However, you could also be using spaces like this for future purposes if you want to display spaces between variables.

 
cout << " " << age << " " << "is your age." << endl;


Where endl also substitutes \n.
Topic archived. No new replies allowed.