- C++ Program contain Four Sections.
- These Sections may be placed in Separate code Files.
- Most popular Compiler systems are UNIX AT & T C++ , Turbo C++ , Microsoft Visual C++.
Include Files |
Class Declaration |
Member Function Definition |
Main Function Program |
Output operator:
Input operator:
- This statement Cout << " c++ is better than c. " ; introduces two new C++ Features i.e Cout and << .
- The operator << is called the Insertion or Put to Operator.
- The identifier Cout is a predefined object that represents the standard output stream in c++.
- << Operator is also known as bitwise left-shift operator.
Note: Both Cout << and printf() are used for displaying an Output.
Input operator:
- The statement Cin >> number; is an input statement.
- The identifier Cin is a predefined object in C++ that represents the standard input stream.
- The operator >> is known as Extraction or get from operator. It extracts the value from the keyboard and assign it to the variable on the right of the identifier Cin.
Note:
- Both scanf() and Cin is used for input values.
- Both << and >> can also be overloaded.
Return Type of main() :
- In C++ main() returns an integer type value to the operating system. Thus every main() in C++ should end with a return(0) statement, otherwise a warning or an error Might occur.
- The default return type for all functions in C++ is int.
Example:
main()
{
...........
...........
return(0);
}
Manipulators:
- Manipulators are the Operators that are used to Format the data display.
- The most commonly used manipulators are endl and setw.
- " endl " manipulator when used in an output statement, it causes a linefeed to be inserted. It has same effect as that of newline character " \n ".
Cascading of I/O Opertors:
- Cout<< "Sum=" << sum<<"\n";
The above Statement first sends the string "Sum=" to Cout and then sends the value of sum.
- Cin>> a >> b;
The values are assigned from Left to Right. If we press two values i.e 10 and 5 from the keyboard then 10 will be assigned to "a" and "5" to b.
- This is one statement and provides one lines of output.
Cout<< "Sum=" << sum<<" , "
<< "Average="<< average<< "\n";
Output:
Sum=30 , Average=7
- This is one statement but provides two lines of output.
<< "Average="<< average<< "\n";
Output:
Sum=30
Average=7
0 Response to "Tutorial on Basic Concepts of C++ Program Part 1"
Post a Comment