A Simple C++ Program

Printing a string using C++


Note: Use new compiler (Code blocks or Dev C++)  to run these C++ programs. Old  Turbo C compiler does not supports some new features of C++.


If you want to run these programs on old Turbo C++ compiler use <iostream.h> instead of <iostream> , do not use ( using namespace std; ) , use { getch(); } to hold run-time screen , use void main() instead of int main() .



Simple Program to print a string in C++


#include<iostream>       \\Include Header File

using namespace std;

int main()
{
   cout << "Printing a simple String \n";    \\ C++ statement
 
   return 0;
}



C++ Program to calculate sum of two numbers

#include<iostream>     

using namespace std;

int main()
{
  int a,b,sum;

  cout << "Enter two numbers. \n";
  cin  >> a >> b;

  sum=a+b;

  cout << "Sum = " << sum <<"\n";

  return 0;
}

Comments

Popular posts from this blog

C++ program to print number pyramid 1 121 12321 1234321 using class.

C++ program to print 0 10 010 1010 pattern using class

A simple C++ program using class