CPP code for Multiplication of two numbers




Multiplication OF TWO NUMBERS


SIMPLE CPP LANGUAGE CODE FOR MULTIPLICATION OF TWO NUMBERS:

#include<iostream.h>
#include<conio.h>
void main()
{int a, b, c;//we take two integer value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a*b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch();
}

And save with extension .cpp
for eg.
MUL.cpp// MUL is the name of the file and .cpp is the extension of the file.
           In the above example, we can multiply integer numbers, not fractional numbers. For example when output screen comes type two numbers like 4 and press enter then type next numbers like 9 then press enter the answer will be displayed on the output screen.
---------------------------------------------------------------------------------------
OUTPUT:
Enter the number: 4
                              9
Ans=36

            This code is for integer numbers if you want to multiply fractional numbers then in above code small changes is there i.e.in the place of int type float. For Multiplication of fractional numbers the code is as follow:

MULTIPLICATION OF TWO FRACTIONAL NUMBERS:
#include<iostream.h>
#include<conio.h>
void main()
{flaot a, b, c;//we take two fractional value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to  accept number
c=a*b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch ();
}
OUTPUT:
Enter the number: 4.5
                              6.7
Ans=30.15

           I hope you like my blog so if any queries are there then write in the comment box. I will solve it. Friends in the next blog I will teach you another program.

CPP code for Multiplication of two numbers CPP code for Multiplication of two numbers Reviewed by Amit Waghmare on July 07, 2019 Rating: 5

No comments: