Here you will get simple C++ program
C++ Language Program for Subtraction of n Numbers.
IT IS THE SMALLEST LOGIC USED FOR CODING OF THIS PROGRAM.
IN WHICH YOU CAN CREATE OWN VARIABLES AND FUNCTIONS.
User will input two numbers and that numbers is subtracted by Subtraction Logic ,then it subtract them and display on screen.
The program coding is given below.
#include <iostream.h>
#include <conio.h>
class SUB
{
int n, sub;
public:
void getdata()
{
cout << "Enter a positive integer: ";
cin >> n;
}
void display()
{
sub=0;
for (int i = 1; i <= n; ++i)
{
sub -= i;
}
cout << "Subtraction = " << sub;
}
};
void main()
{
clrscr();
SUB s1;
s1.getdata();
s1.display();
getch();
}
#include <conio.h>
class SUB
{
int n, sub;
public:
void getdata()
{
cout << "Enter a positive integer: ";
cin >> n;
}
void display()
{
sub=0;
for (int i = 1; i <= n; ++i)
{
sub -= i;
}
cout << "Subtraction = " << sub;
}
};
void main()
{
clrscr();
SUB s1;
s1.getdata();
s1.display();
getch();
}
Output will be given after you compile it.