<iostream> : Contains function prototypes for the C++ standard input and standard output functions. This header file replaces header file <iostream.h>
<iomanip> : Contains function prototypes for stream manipulators that format streams of data. This header file replaces header file <iomanip.h>
<cmath> : Contains function prototypes for math library functions. This header file replaces header file <math.h>
<cstdlib> : Contains function prototypes for conversions of numbers to text, text to numbers, memory allocation, random numbers and various other utility functions. This header file replaces header file <stdlib.h>.
<ctime> : Contains function prototypes and types for manipulating the time and date. This header file replaces header file <time.h>
Important Component/Features of C++ Language
Comment
Header file & preprocessor directive
Function
Body
Comment:
//Author-ICT Lecturer /* My first program in C++ and there will be more programs after this"/
Headerfile : #include <iostream> using namespace std;
Function :
int main ()
{
Body: cout <<"Hello World!";
cout <<"\n";
system ("PAUSE");
return 0;
}
The purpose to insert a comment: 1. To document a program
2. To improve the program readability
Line comment : discards everything from where the pair of slash signs (//) are found up to the end of that same line @ normally used for singleline comment
Block comment discards everything between the /* and the first appearance of the */ with the possibility of including multiple lines @ possibly containing many lines
Header file is a text file containing small bits of program code, which is used to describe the contents of the main body of code to other modules
Header file:
<iostream>
<cmath>
Preprocessor directive
#include
#include <iostream> : declare objects that control reading from and writing to the standard streams
#include <iostream> : cin, cout, DLL
cin : console input
cout : console output
#include<cmath> : Mathematical declarations to perform calculations
#include<cmath> : pow, sqrt
pow : Raise to power
sqrt : Return the squareroot of x
Example
cout<<"The square root of the radius is: "<<sqrt(radius)<<endl;
cout<<"The area of the circle is: "<<3.1416 pow(radius, 2)<<endl;
Function: a group of code statements which are given a name
BODY The body may consists of:
1. Reservedword
2. Variabledeclaration
3. Input/Output console
4. C++ statement
5. Return statement