Question
#include int Square(int value); int Cube(int value); int main () { /* variable definition: */ int intValue, menuSelect,Results; intValue = 1; // While a positive
#include
int Square(int value); int Cube(int value);
int main ()
{
/* variable definition: */
int intValue, menuSelect,Results;
intValue = 1;
// While a positive number
while (intValue > 0)
{
printf ("Enter a positive Integer : ");
scanf("%d", &intValue);
if (intValue > 0)
{
printf ("Enter 1 to calculate Square, 2 to Calculate Cube : ");
scanf("%d", &menuSelect);
if (menuSelect == 1)
{
// Call the Square Function
Results = Square(intValue);
printf("Square of %d is %d ",intValue,Results);
}
else if (menuSelect == 2)
{
// Call the Cube function
Results = Cube(intValue);
printf("Cube of %d is %d ",intValue,Results);
}
else
printf("Invalid menu item, only 1 or 2 is accepted ");
}
}
return 0;
}
/* function returning the Square of a number */
int Square(int value)
{
return value*value;
}
/* function returning the Cube of a number */
int Cube(int value)
{ return value*value*value;
}
Modify the original code and add an additional function of your choice. The function should be unique and something you created for this assignment. Support your experimentation with screen captures of executing the new code. Prepare a test table with at least 3 distinct test cases listing input and expected output for your unique functionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started