Site icon TestingDocs.com

C Program to find the product of two integer numbers

Overview

Let’s learn how to write a C program to find the product of two integer numbers using Code::Blocks IDE. We will prompt the user to enter two numbers. The C program stores the two numbers computes the product and prints the result to the screen.

C Program

Let’s write the source code for the program using Code::Blocks IDE. The steps to create the program are as follows:

 

The following C code to find the product of two integer numbers. The program prompts the user to enter two numbers. Declare three int data type variables. Two to store the number and one to store the product of the numbers. The multiplication operator in C language is the * operator.

 

/* **************************************************************
* Program Description:
* C Program to read two integers from the keyboard
* and prints the product of the two numbers
*
* Filename: product.c
* C Tutorials - www.TestingDocs.com
*****************************************************************/
/* Standard Header I/O File */
#include

int main()
{
    /* Local variables definitions */
    int number1;
    int number2;
    int result;

// Prompt the user to enter two numbers
    printf("Enter the first number:= \n");
    scanf("%d",&number1);
    printf("Enter the second number:= \n");
    scanf("%d",&number2);

//Calculate the product
    result = number1 * number2;

 // Print the result
    printf("Product of the two numbers = %d \n",result);
    return 0;
}



Sample Output

Build and Run the project.

Resolve any compilation errors if any.

Run a sample test case to verify the output. A sunny day test case or the happy path test case output is shown below:

—————-

Enter the first number:=
16
Enter the second number:=
24
Product of the two numbers = 384

——————-

Screenshot

The screenshot of the C program ouput.

 

That’s it. We have successfully created and run a C program to compute the product of the two numbers.

C Tutorials

C Tutorials on this website can be found at:

https://www.testingdocs.com/c-language-tutorial/

Code::Blocks

Code::Blocks Tutorials on this website can be found at:

https://www.testingdocs.com/code-blocks-tutorials/

For more information on Code::Blocks IDE, visit the official website:

https://www.codeblocks.org/

Exit mobile version