Dremendo Tag Line

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 <stdio.h>
#include <conio.h>
#include <math.h>

int main()
{
    int a,b,p;
    printf("Enter 2 negative integer numbers\n");
    scanf("%d%d",&a,&b);
    p=abs(a) * abs(b);
    printf("Product = %d",p);
    return 0;
}

Output

Enter 2 negative integer numbers
-5
-8
Product = 40
video-poster