Monday, July 18, 2011

Using "cout" statement in C++

"cout" Statement:-
                                 "coutis statement is used to print something  on the output screen in C++ language program. now this is a simple example of"cout"statement.


Program:-


#include<iostream.h>
#include<conio.h>
void main(void)
{
clrscr();
cout<<"My name is ammar"<<endl;
cout<<" I live in wah cantt"<<endl;
cout<<" I am student"<<endl;
getch();
}


Output:-
                             My name is ammar
                             I live in wah cantt
                             I am student


Note:-
          There is not much difference between "C" and "C++"  in syntax as you can see four changes in this program.

  1. we us ""#include<iostream.h>" instead of "#include<stdio.h> in c++"  .
  2. we use "cout" instead of "printf" in c++ .
  3. we use endl for new line however you can also use \n in c++.
  4. we use "<<" instead of parentheses in c++

No comments:

Post a Comment