Cpp program to multiply two floating point numbers
In this program, the user is asked to enter two numbers(integer numbers). then it calculating product of those numbers and display on the screen
Here, when the user enters the numbers, the first number stored in variable num1 and the second number stored the variable num2. Then, the product of the numbers is stored in the variable product.
Source Code:
#include <iostream> #include <conio.h> using namespace std; float multiply(float x, float y);//function declaration or prototype int main() { float num1; //variable for store first numbers float num2; //variable for store second numbers float product; //variable for store result of product //read numbers enterd from user cout << "Enter the first numbers" << endl; cin>>num1; //stored first number- get input from user cout << "Enter the second numbers" << endl; cin>>num2; //stored second number- get input from user product=multiply(num1, num2);//calling function and stored returning the result by function; //print product of numbers cout<<"Product of two numbers "<<product<<endl; getch(); return 0; } //function definition float multiply(float x, float y) { return (x*y); //return the multiplication result to main }
More C++ Multiply Program:
Post a Comment