A Simple C++ Program
Printing a string using 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
Post a Comment