Calculate the product of two numbers using a function. - C Function

C examples for Function:Function Definition

Description

Calculate the product of two numbers using a function.

Demo Code

#include <stdio.h>

int val1, val2, val3;

int product(int x, int y);

int main( void )
{

   printf("Enter a number: ");
   scanf("%d", &val1);


   printf("Enter another number: ");
   scanf("%d", &val2);

   val3 = product(val1, val2);/*from   w ww  . j  a v  a  2s. c  om*/

   printf ("%d times %d = %d\n", val1, val2, val3);

   return 0;
}

int product(int x, int y){
    return (x * y);
}

Result


Related Tutorials