Input 2 negative integers and print the product after removing the negative sign using mathematical functions in C++
Mathematical Functions - Question 1
In this question, we will see how to input two negative integer numbers and print the product of the numbers after removing their negative sign in C++ programming using the mathematical functions. To know more about mathematical functions click on the mathematical functions lesson.
Q1) Write a program in C++ to input two negative integer numbers and print the product of the numbers after removing their negative sign using the abs() function.
Program
#include <iostream>
#include <conio.h>
#include <cmath>
using namespace std;
int main()
{
int a,b,p;
cout<<"Enter two negative integer numbers\n";
cin>>a>>b;
p=abs(a) * abs(b);
cout<<"Product = "<<p;
return 0;
}
Output
Enter two negative integer numbers -5 -8 Product = 40