# C++ Exercises

## C++ Program to calculate subtraction of two numbers.

Let see the program subtraction two numbers.

```Example:
Declare three variables they are integer or float data types x, y,z.
Declare one int data type and one float datatype, then store float data type.
Declare two float data type, then store float data type.
Declare two integer data types, then store integer data type.
Input x=10,y=20
Then z=x-y
subtraction two numbers z=-10.
Input x=20,y=10
Then z=x-y
subtraction two numbers z=10.
Input x=10,y=20.5
Then z=x-y
subtraction two numbers z=-10.5
Input x=20.5,y=10
Then z=x-y
subtraction two numbers z=10.5
```

```#include <iostream>

using namespace std;
int main()
{
int number1,number2,sub;
cout<<"Enter First number :";
cin>>number1;
cout<<"Enter second number :";
cin>>number2;
sub=number1-number2;
cout<<" Subtraction of two numbers :"<<sub<<endl;
return 0;
}

```

##### Output:

```Enter First number :10
Enter second number :20
Subtraction of two numbers :-10

Enter First number :20
Enter second number :10
Subtraction of two numbers :10

```

```#include <iostream>

using namespace std;
int main()
{
int number1;
float number2,sub;
cout<<"Enter First number :";
cin>>number1;
cout<<"Enter second number :";
cin>>number2;
sub=number1-number2;
cout<<" Subtraction of two numbers :"<<sub<<endl;
return 0;
}

```

##### Output:

```Enter First number :10
Enter second number :20.5
Subtraction of two numbers :-10.5

```

```#include <iostream>

using namespace std;
int main()
{
float number1,number2,sub;
cout<<"Enter First number :";
cin>>number1;
cout<<"Enter second number :";
cin>>number2;
sub=number1-number2;
cout<<" Subtraction of two numbers :"<<sub<<endl;
return 0;
}

```

##### Output:

```Enter First number :10.5
Enter second number :7.5
Subtraction of two numbers :3

```