
C++ Basic
A Simple C++ Program

iostream is just like we include stdio.h in c program.
It contains declarations for the identifier cout and the insertion operator<<.
iostream should be included at the begning of all prorams that use input/output statements.
A namespace is a declerative region.
A namespace is a part of the program in which certain names are recorganised out side
of the namespece they unknown.
namespace define a scope for the identifies that are used in a program.
using and namespace are the kewords of c++.
std is the namespace where ANSI c++ standard class liberies are defined.
Various program components suchas cont cin,endl,are define within std namespace.
If we don't use the using directive at top, we have to add the std followed by :: in the program
before identifier.
Std::cout<<"Hello World";
In c++ main() return on integer type value.
Therefore, every main() in c++ should endl with a return 0; statement; error will occur.
Insertion Operaton<<
cout<<"hello world";
The operator << is called insertion operation.
It insert the contents of the variable on its right to the object on its left.
The identifier cout is a predefined object that represent standard out stream in c++.
Here, Sreen represents the output. We can also redirect the output to other output devices.
The operators << is used as bitwise left shit operator also.
Program #1


The endl manipulator and \n has same effect. Both inserts newline to output.
But Difference is endl immediate flush to the output while in \n do not.
Extrecion Operatior
cin>>number1;
The operator >> is called the exactraction operator.
It extracts (or takes) the values from keyboard and assings it to the variable
on its right.
The identifiers cin is a predefined object that represents standard input stream in c++.
Here, standard input stream represents the keyboard.
The operator >> is used as bitwise right shift operator also.
Program #2

0 Comments