Tuesday, 10 July 2012

Program to add two numbers in C++


Code -


/* Program to add two numbers in C++ */

//__ "\n" is used for new line and "\t" for a tab (spaces) ___

//__ cin is to take the input and cout is used to dispaly the output ___

#include<iostream>

//___ Header file in C++ where the standard input/output functions are defined ___

#include<conio.h>

using namespace std;

int main()
{
int first_number = 0, second_number = 0, sum = 0;

cout << "\n\t\t __ Program to add two numbers in C++ ___";

cout << "\n\n  Enter the First number  - ";

cin >> first_number;

cout << "\n\n  Enter the Second number - ";

cin >> second_number;

sum  = first_number + second_number;

cout << "\n\n\t\t    ___  Sum of " << first_number << " and " << second_number << " is " << sum << " ____";

getch();

}

No comments:

Post a Comment