I guess those answers confused you even more.
Basically you need to write three diff funcs here and inside the main they have to be called three times.
To multiply include this :
int mulTwoNumbers(int operand1, int operand2)
{
return (operand1 * operand2);
}
and to subtract use this
int subTwoNumbers(int operand1, int operand2)
{
return (operand1 - operand2);
}
Now the writing of functions part is over.
Modify the main as :
int main()
{
int num1, num2;
printf("\nEnter the first number: ");
scanf("%d" , &num1);
printf("\nEnter the second number: ");
scanf("%d" , &num2);
printf("\nThe sum is %d\n", addTwoNumbers(num1, num2));
printf("\nThe product is %d\n", mulTwoNumbers(num1, num2));
printf("\nThe difference is %d\n", subTwoNumbers(num1, num2));
}
You could have combined these two scanfs and these printfs into one.
I guess you are clear now.
@The Protostar.
I considered simply pointing out the missing function definitions, but his reply to my first post seemed so clueless that I decided to investigate his (brief) post history to help me decide on a response. It appears to me that he is here looking only for completely coded solutions. When he gets one, he nukes the content of his posts and departs the thread without thanking the code poster.
I was hoping that he might actually submit the code I gave. I think he deserves to get caught for cheating if he is submitting code that he doesn't even look at.
O dear stop making up a story about me :|, I'm not cheating at all I'm new with all the programming stuff plus I'm an international student who's studying foundation at the moment so I was hoping to learn as much as I can about c++ and C# before going to uni any way thanks for all the help. about deleting the previous questions its because I didn't get the answers so I said whats the point of leaving the question !!
and by the way once you gave me the code I tried to understand it as much as I can, spent 3 hours on you're answer..
yeah I did thanks to you and all the others but I need to practice more I'm trying to understand as much as i can I just bought my self a book "C for absolute beginners" it wasn't that much helpful as I was expecting.
I answered the question just like you said but my program still not working
#include <stdio.h>
int addTwoNumbers(int, int);
int subTwoNumbers(int, int);
int mulTwoNumbers(int, int);
int main()
{
int num1, num2;
printf("\nEnter the first number");
scanf("%d", &num1);
printf("\nEnter the second number");
scanf("%d", num2);
printf("\nThe sum is %d\n", addTwoNumbers(num1, num2));
printf("\nThe product is %d\n", mulTwoNumbers(num1, num2));
printf("\nThe difference is %d\n", subTwoNumbers(num1, num2));
}
int addTwoNumbers(int operand1, int operand2)
{
return operand1 + operand2;
}
int subtractTwoNumbers(int operand1, int operand2)
{
return operand1 - operand2;
}
int multiplyTwoNumbers(int operand1, int operand2)
{
return operand1 * operand2;
}