filmov
tv
1. Write a program in C++ to print the message 'Hello World I am a C++ Program'?
Показать описание
Explanation:-
Line 1 and Line 2 is a special type of statement called a preprocessor directive. Preprocessor directives tell the compiler to perform a special task. In this case, we are telling the compiler that we would like to add the contents of the iostream header and conio header to our program. The iostream header allows us to access functionality from the iostream library, which will allow us to write text to the screen.
Line 3 declares the main() function,Every program must have a main() function.
Lines 4 and 9 tell the compiler which lines are part of the main function. Everything between the opening curly brace on line 4 and the closing curly brace on line 9 is considered part of the main() function.
Line 5 Clrscr() is a predefined function in "conio.h" (console input output header file) used to clear the console screen. It is a predefined function, by using this function we can clear the data from console (Monitor). Using of clrscr() is always optional but it should be place after variable or function declaration only.
Line 6 is our first statement (you can tell it’s a statement because it ends with a semicolon), and it is an output statement. cout is a special object that represents the console/screen. The double less than symbol is an operator (much like + is an operator in mathematics) called the output operator. cout understands that anything sent to it via the output operator should be printed on the screen. In this case, we’re sending it the text “Hello world! I am a C++ Program”.
Line 7 getch() is a predefined function in "conio.h" (console input output header file) will tell to the console wait for some time until a key is hit given after running of program.
By using this function we can read a character directly from the keyboard. Generally getch() are placing at end of the program after printing the output on screen.
Line 8 is a new type of statement, called a return statement. When an executable program finishes running, the main() function sends a value back to the operating system that indicates whether it was run successfully or not.
Line 1 and Line 2 is a special type of statement called a preprocessor directive. Preprocessor directives tell the compiler to perform a special task. In this case, we are telling the compiler that we would like to add the contents of the iostream header and conio header to our program. The iostream header allows us to access functionality from the iostream library, which will allow us to write text to the screen.
Line 3 declares the main() function,Every program must have a main() function.
Lines 4 and 9 tell the compiler which lines are part of the main function. Everything between the opening curly brace on line 4 and the closing curly brace on line 9 is considered part of the main() function.
Line 5 Clrscr() is a predefined function in "conio.h" (console input output header file) used to clear the console screen. It is a predefined function, by using this function we can clear the data from console (Monitor). Using of clrscr() is always optional but it should be place after variable or function declaration only.
Line 6 is our first statement (you can tell it’s a statement because it ends with a semicolon), and it is an output statement. cout is a special object that represents the console/screen. The double less than symbol is an operator (much like + is an operator in mathematics) called the output operator. cout understands that anything sent to it via the output operator should be printed on the screen. In this case, we’re sending it the text “Hello world! I am a C++ Program”.
Line 7 getch() is a predefined function in "conio.h" (console input output header file) will tell to the console wait for some time until a key is hit given after running of program.
By using this function we can read a character directly from the keyboard. Generally getch() are placing at end of the program after printing the output on screen.
Line 8 is a new type of statement, called a return statement. When an executable program finishes running, the main() function sends a value back to the operating system that indicates whether it was run successfully or not.