C++ basics, C++ programming,C++ language.

Hi there my name is Bilal Ahmad and today I am here to tell some basic concepts in C++ and today I will make the subtraction calculator in C++ in which we take the value from the user. In this tutorial, we simply make the calculator that will subtract the user given values and we will also explain actually what happened in the program.

In this tutorial we expect that input 2 is greater than input 2;

Simple Subtraction Calculator In C ++

#include<iostream>
using namespace std;
int main()
{
   int input1=0,input2=0,subtract=0;
     cout<<"please enter the 1st number=;
     cin<<input1;

      Cout<<"please enter the 2nd number=;
       cin>>input2;

       subtract=input2-input1;


        cout<<the final value after subtraction=<<subtract<<endl;

     return 0;
}



So Explanation of this channel.

In this video first of all the iostream is used to get input and output of the values.

the int main is used to define functions.

input 1 and 2 are used to get value from users.

the subtract variable is used to subtract value from input 2 to input 1.

the cout gives the final result.


Example of this code.

let's take the example that user input values 10 and 15 as inputs 1 and 2 respectively.

the values stored in the input values.

and then the final result saved in the subtract value

finally, we get the result  5.


so hope to see you in the next code till best of luck 

with best regards.

Bilal Ahmad.



No comments

Powered by Blogger.