Output
To print something in C++ we will use the object cout
with the operator <<
. The message you want to output must be enclosed with double quotes.
For example:
1234567#include <iostream> using namespace std; int main() {     cout << "I love C++!";     return 0; }
To get the same result, you can also write the code without using namespace std
:
#include <iostream>
int main() {
std::cout << "I love C++!";
return 0;
}
Pay attention that you can use the multiple insertion operator and add as many cout
objects as you want:
12345678#include <iostream> using namespace std; int main() {     cout << "I love programming! ";     cout << "I love C++" << " and " << "Python!";     return 0; }
Every
cout
object or<<
operator doesn’t write your code to a new line.
Kiitos palautteestasi!
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Awesome!
Completion rate improved to 3.33
Output
Pyyhkäise näyttääksesi valikon
To print something in C++ we will use the object cout
with the operator <<
. The message you want to output must be enclosed with double quotes.
For example:
1234567#include <iostream> using namespace std; int main() {     cout << "I love C++!";     return 0; }
To get the same result, you can also write the code without using namespace std
:
#include <iostream>
int main() {
std::cout << "I love C++!";
return 0;
}
Pay attention that you can use the multiple insertion operator and add as many cout
objects as you want:
12345678#include <iostream> using namespace std; int main() {     cout << "I love programming! ";     cout << "I love C++" << " and " << "Python!";     return 0; }
Every
cout
object or<<
operator doesn’t write your code to a new line.
Kiitos palautteestasi!