C++ uses Notation that may apper strange to non-programer.
We now consider a simple program that prints a line of Text.The program and its output are shown in fig 1.2.
This program illustrates several important Feature of the C++ language.
We consier each line of the program detail.
// fig 1.2 fig0 02.cpp // A firs program in C++ #include <iostream> // function main begins program execution int main () { std::cout<<"welcome to C++!\n"; return 0;//indicated program endded sucessfuly }//end function main |
Welcome to C++ |
Fig 1.2
Line 1 and 2
//fig. 1.2 fig 01.cpp
//A firs program in C++
Each begin // indicated that remainder of each line is comment .
Programmers insert comment to document program and improve program readbility.
Coment also Help other people read and understand your program.
Comment are ingored by the C++ compiler and do not cause any machine-language object code to generated.The comment A first program in C++ describes the porpose of the program.
A comment begining with // is called a single-line comment because the comment terminates at the end of the line.
[Note: C++ programers also may use C's comment style in which a comment -possibly containing many lines-begins with/*and ends with*/,but this is discouraged.]
0 Response for the "A Simple program:Printing A line of Text"
Post a Comment