Reference no: EM131117506
Which will either square, cube or shrink an integer based off a menu selection. I can not seem to allow for a float to be the result of the shrink.
Every time I try to allow for a float I receive multiple errors.
The code that works with a basic integer is below, need something that returns a float result for the shrink in C.
#include
int main ()
{
/* variable definition: */
int intValue, menuSelect,Results;
intValue = 1;
// While a positive number
while (intValue > 0)
{
printf ("Enter a positive Integern: ");
scanf("%d", &intValue);
if (intValue > 0)
{
printf ("Enter 1 to calculate Square, 2 to Calculate Cube, Enter 3 to Calculate Shrink n: ");
scanf("%d", &menuSelect);
if (menuSelect == 1)
{
// Call the Square Function
Results = Square(intValue);
printf("Square of %d is %dn",intValue,Results);
}
else if (menuSelect == 2)
{
// Call the Cube function
Results = Cube(intValue);
printf("Cube of %d is %dn",intValue,Results);
}
else if (menuSelect == 3)
{
Results = Shrink(intValue);
printf("shrink of %d is %dn", intValue,Results);
}
else
printf("Invalid menu item, only 1 or 2 or 3 is acceptedn");
}
}
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;
}
int Shrink(int value)
{
return value*1/2;
}
What is the company cost of equity
: The Muse Co. just issued a dividend of $ 2.75 per share on its common stock. The company is expected to maintain a constant 5.8 percent growth rate in its dividends indefi nitely. If the stock sells for $ 59 a share, what is the company’s cost of equ..
|
What is the company pretax cost of debt
: Mudvayne, Inc., is trying to determine its cost of debt. The fi rm has a debt issue outstanding with 18 years to maturity that is quoted at 107 percent of face value. The issue makes semiannual payments and has an embedded cost of 6 percent annually...
|
Safety representative for your work group
: You work in a large department store and are the newly appointed health and safety representative for your work group. The organisation is wanting in compliance with its health and safety compliance.
|
Describe what makes that decision unethical
: Describe what makes that decision unethical. Present an alternative ethical and legal solution to the decision focusing on the organization's responsibility to its stakeholders.
|
Construct a simple simulation of ordering
: You will use threads to construct a simple simulation of ordering at a coffee shop - Which will either square, cube or shrink an integer based off a menu selection. I can not seem to allow for a float to be the result of the shrink.
|
Environmental issues in today political world
: Politicians that follow the dictates of their constituencies and the demands of reelection are followers. Is there a place for political leaders on environmental issues in today's political world?
|
Question regarding the monetary policy
: 1. What policy instruments does the Fed use for the monetary policy?
|
Adapted from a case written by glyn jones
: Matalvi Engineering Ltd has its headquarters in Hamilton, New Zealand, with manufacturing plants in South Auckland and Christchurch. The company manufactures equipment for the dairy industry. In its early years it focused on the domestic market, b..
|
Display a calendar for a specified month
: You also can run the program without the year. In this case, the year is the current year. If you run the program without specifying a month and a year, the month is the current month.
|