Loading...
C Program to multiply two floating-point numbers

C Program to Multiply Two Floating-Point Numbers

In this example, we will learn to take two numbers as user input , then multiply them and print the result on screen.

Remainder :

To understand this example, you should have the knowledge of the following C programming topics:


Program to Multiply Two Numbers

#include <stdio.h>

int main() {
  int num1, num2, product;
  printf("Enter two number : ");
  scanf("%d %d", &num1, &num2);
  product = num1 * num2;
  printf("The product of %d and %d is %d", num1, num2, product);
  return 0;
}

Output

Enter two number : 23 12
The product of 23 and 12 is 276

Working of the above program

  • First we declare three integer variables num1, num2 and sum, in which num1, num2 used to store integers and product to store the sum of both integers .
  • int num1, num2, product;
  • Then we asked the user to enter two integers.
  • printf("Enter two number : ");
  • Then we take the user input using scanf() function and store the entered value in num1 and num2 variable respectively.
  • scanf("%d %d", &num1, &num2);
  • Then we multiply num1 and num2 and save the resultant value in variable product.
  • product = num1 * num2;
  • Finally, we print the value of num variable using %d format specifier in printf() function.
  •   printf("The product of %d and %d is %d", num1, num2, product);

- Related Topics