C++ is a general-purpose programming language. C++ is used to create computer programs. Anything from art applications, music players and even video games! C++ was derived from C, and is largely based on it.
RSES CODE PLAYGROUND DISCUSS TOP LEARNERS Hello, World! 10 2/6 Your First C++ Program The C++ compiler ignores blank lines. In general, blank lines serve to improve the code's readability and structure. Whitespace, such as spaces, tabs, and newlines, is also ignored, although it is used to enhance the program's visual attractiveness. #include <iostream> using namespace std; int main() { cout << "Hello world!"; return 0; } Try It Yourself In our code, the line using namespace std; tells the compiler to use the std (standard) namespace . The std namespace includes features of the C++ Standard Library.
Statements A block is a set of logically connected statements, surrounded by opening and closing curly braces. For example: { cout << "Hello world!"; return 0; } You can have multiple statements on a single line, as long as you remember to end each statement with a semicolon . Failing to do so will result in an error.
Main Program execution begins with the main function, int main() . #include <iostream> using namespace std; int main() { cout << "Hello world!"; return 0; } Try It Yourself Curly brackets { } indicate the beginning and end of a function, which can also be called the function's body. The information inside the brackets indicates what the function does when executed. The entry point of every C++ program is main() , irrespective of what the program does.
Comments
Post a Comment