multiplication of two numbers using pointer with function in c language ?
Answers
Answer:
#include <stdio.h>
#include <stdlib.h>
int multiplyNum(int , int);//function declaration or prototype
int main()
{
int num1,num2,product;//variable declaration
printf("Enter the two number ");
scanf("%d %d",&num1,&num2);//taking two number as input from user
product=multiplyNum(num1,num2);//calling the function
//The product value (returned by the function) is stored in product variable.
printf("The product of these numbers :%d",product);
//display the product value
getch();
return 0;
}
int multiplyNum(int a, int b)//defining function based in declaration
{
int result=a*b;//find product of two numbers
//and result stored in result variable
return result;//returning result
}
Explanation:
Answer:
Create two variables to store two numbers as input (num1 and num2) provided by the user. Create a variable to store the sum of these numbers: sum. Using scanf() function, store the second input value in num2.