Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// C code // This program will provide options for a user to calculate the square. // or cube of a positive integer input by

// C code
// This program will provide options for a user to calculate the square.
// or cube of a positive integer input by a user.
#include
// Function prototypes
Int squares (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 acceptable );
}
}
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;
}
1. Using the Square and Cube function as models, create an application that includes a function named Shrink that would take an integer and return the integer divided by 2. (Hint: Your return variable type should be double.) support your experimentation with sceeen captures of executing the code.
2. Prepare a new test table with at least 3 distinct test cases listing input and expected output for the new code you created for the Shrink function.
3. What would happen if you removed the following code from our design ?
If intValue > 0
Support your argument with screen captures of executing the new code.
4. 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 function.
.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions