Sunday, December 12, 2010

Basic C program to multiply two numbers



#include <stdio.h>

int mult ( int x, int y );

int main()
{
  int x;
  int y;
 
printf( "Please input two numbers to be multiplied: \n" );

printf( "Enter Number 1: " );
 scanf( "%d", &x );

printf( "Enter Number 2: " );
scanf( "%d", &y );

printf( "The product of your two numbers is %d\n", mult( x, y ) );

getchar();
return 0;
}

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

2 comments:

Anonymous said...

this is wrong.. i just tested

Tharindu Edirisinghe said...

I double checked it. Works fine. May be there's a problem with your compiler. Check it

Post a Comment