Tuesday 10 July 2012

Program to subtract two numbers in C++


Code -



/* Program to subtract 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, subtract = 0;

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

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

cin >> first_number;

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

cin >> second_number;

subtract  = first_number - second_number;

cout << "\n\n\t\t    ___  Subtraction of " << first_number;

        cout <<  " and " << second_number << " is " << subtract << " ____";


getch();

return 0;

/*____ return 0 tells the compiler that program

has executed successfully without any error ____ */

}

No comments:

Post a Comment