hello can you help me to right a cod | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

hello can you help me to right a cod

24th Jan 2018, 7:33 PM
Hely Hely
Hely Hely - avatar
5 Answers
+ 2
yes. Write print("Hello, world!")
24th Jan 2018, 7:35 PM
Saidmamad Gulomshoev
Saidmamad Gulomshoev - avatar
+ 2
C++ version of that: #include <iostream> using namespace std; int main() { cout << “Hello, world!”; }
24th Jan 2018, 9:21 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 1
thanks
25th Jan 2018, 12:25 PM
Hely Hely
Hely Hely - avatar
0
Explanation of both C++ versions: Mine: #include <iostream> //This tells the compiler to include the input and output header. It allows you to output to the console and get input from the user. using namespace std; //A namespace in C++ is a group of functions, classes, anything like that organized in a system similar to folders. “std” is the standard namespace. It is considered bad practice to use this because it could cause an error if you are using multiple namespaces. int main() { /*code*/} //This defines the main function. That is what runs when the program starts. cout << “Hello, world!”; //This is what actually outputs the text. cout is a keyword in the standard namespace for console output, << is the output operator. It is also used for output to files. The semicolon shows that the statement is over. @Vlad’s version: //Most stayed the same, but some differences. Instead of “using namespace std;”, it has “std::” in front of everything from that namespace. This avoids errors that can occur in my version, but is not necessary if you are only using one namespace because the error can only come from conflicting namespaces. std::cout << “Hello, world!” << std::endl; //There are a few new things in this. First, the extra “<<“. You can have as many of these as you want, they will just all be outputted. Second, std::endl is like pressing enter on the keyboard, it ends the line. endl also does this: cout.flush(). For just ending the line, you could do this: std::cout << “Hello, world!\n”; \n just ends the line.
24th Jan 2018, 11:08 PM
Jacob Pembleton
Jacob Pembleton - avatar
- 1
Better C++ version of that: #include <iostream> int main() { std::cout << “Hello, world!” << std::endl; return 0: }
24th Jan 2018, 9:56 PM
Vlad Serbu
Vlad Serbu - avatar