hello,
I am building an application where I have two integers and I have to add them or multiply.
I have to use a function to add/multiply this two numbers and call it from the main.
I have done this so far.
int main()
{
int user_choice;
int num1;
int num2;
int ans; // ans stands for answer
switch(user_choice){
case add: printf(" Enter number "); // if user choose addition write "enter number"
scanf("%d",&num1); // scan number
printf("Added to "); // ask for second number
scanf("%d", &num2); // scan second number
ans = num1 + num2; // add both numbers and place it in variable ans
printf("sum is: %d\n",ans); // show answer
How can I put that into a function and how do I call it from the main as I am using switch function?
Thank you in advance