Site icon Codeforcoding

C program to multiply two numbers

C program to multiply two numbers

Multiplication

C program to multiply two numbers

In this tutorial, we will discuss the C program to multiply two numbers.

In this topic, we will learn how to multiply two integer number in the C programming language

Multiply two integer value

Program 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int f_no,s_no,product;
    printf("Enter the first number: ");
    scanf("%d",&f_no);//get input from user for first number
    
    printf("Enter the second number: ");
    scanf("%d",&s_no); //get input from user for second number
    
    product=f_no*s_no;  //calculate product
    
    printf("The multiplication of two numbers are: %d\n",product);
    //display of product on the screen
    getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

Enter the first number: 12
Enter the second number: 32
The multiplication of two numbers are : 384

 

This is a simple C program to find the product of two integer numbers.

In the above program, we declared two different integer values such as  12 and 32 stored in variables f_no, s_no respectively.
Then, we can find the product of given numbers using the * operator

finally, we could display the result on the screen using printf() function in C language.

Multiply two floating point value

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("find Product of floating point value\n");
   float f_No,s_No,product;
    printf("Enter the first number: ");
    //store the floating point value in variable f_No
    scanf("%f",&f_No);
    printf("Enter second number: ");
    scanf("%f",&s_No);
    //store the floating point value in variable s_No

product=f_No * s_No;
//multiply two numbers and store the result in variable product

printf("the Product is : = %.3f",product);
//display result up to 3 decimal places
getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

find Product of floating point value
Enter the first number: 4.3
Enter second number: 3.21
the product is: 13.803

This is a simple C program to find the product of two floating point numbers.

In the above program, we declared two different floating point values such as  4.3 and 3,21 stored in variables f_No, s_No respectively.
Then, we can find the product of given numbers using the * operator in c

finally, we could display the result on the screen using printf() function in C language.

 

Similar post

C++ program to multiply two numbers using function

Java program to multiply two numbers using method

Python program to multiply two numbers using function

C# program to multiply two numbers using function

PHP program to multiply two numbers using function

 

Find product of two numbers using method in Java

Find product of two numbers using recursion in Java

 

C program to multiply two numbers 

C++ program to multiply two numbers

Java program to multiply two numbers 

Python program to multiply two numbers 

C# program to multiply two numbers 

PHP program to multiply two numbers 

JavaScript program to multiply two numbers 

 

Calculate the total of array elements in Java

Calculate the total of array elements in C

Calculate the total of array elements in C++

Java program to calculate sum of array elements

C program to calculate sum of array elements

Java Program to calculate average of array

C Program to calculate average of array

Java Program to calculate average of odd and even numbers in an array

Java Program to calculate average of odd and even numbers

C Program to calculate average of odd and even numbers in an array

C Program to calculate average of odd and even numbers

C++ Program to calculate average of odd and even numbers in an array

C++ Program to calculate average of odd and even numbers

 

 

Java program to multiply two numbers
CPP program to multiply two numbers
Exit mobile version