0

Not get desired output in c++

#include <iostream> using namespace std; int main() { cout << " c \n"; cout << " + \n"; cout <<" + "; return 0; } Why I am not getting output which is C + + It is question from c++ course lesson 3

11th Mar 2024, 4:23 AM
Om Kharate
Om Kharate - avatar
4 Answers
+ 4
#include <iostream> using namespace std; int main() { cout << "C\n"; cout << "+\n"; cout <<"+"; return 0; } I think you should remove the space and use a capital C.
11th Mar 2024, 4:29 AM
Mafdi
Mafdi - avatar
+ 2
you really don't need all those cout. You can condense it to one line. cout<<"C\n+\n+";
11th Mar 2024, 5:29 AM
Bob_Li
Bob_Li - avatar
0
here is something to explore. Google 'iomanip setw()' and 'C++ for-each loop' to learn more... #include <iostream> #include <iomanip> using namespace std; int main() { int tab = 10; for(auto c : "PYTHON") cout<<setw(tab)<<c<<'\n'; }
11th Mar 2024, 9:29 AM
Bob_Li
Bob_Li - avatar