Learn C++ beginer programs

July 5, 2009

Write a program to display the input

Filed under: cin,cout,first program — snehilkhanor @ 6:03 pm
This is an ideal first program for learning “cin”
Two numbers are taken from the user and then displayed as output.

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int a,b;
  7. cout<<”enter first no. “;
  8. cin>>a;
  9. cout<<”enter second no. “;
  10. cin>>b;
  11. cout<<”First no. is “<<a;
  12. cout<<”\nSecond no.is “<<b;
  13. getch();
  14. }

Write a program to output a messege

Filed under: cout,first program — snehilkhanor @ 5:55 pm
This is an ideal First C++ (CPP) program.
All necessary things are described with in the program in comments.

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h> //These are the Header files and are essential..
  2. #include <conio.h> // They varies program to program.
  3. void main() //This is a special type of function.Program starts and ends in MAIN.
  4. {
  5. clrscr(); //This clears previous outputs from the output screen
  6. cout<<”Hello India”; //This is responsible for diplaying a messege
  7. cout<<”\nThis is my first C++ programme”;
  8. getch(); //This helps to sustain the output on Screen.
  9. }

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.