What you need to know about C program language

158 views 2 pages ~ 311 words Print

Modeling the Square and Cube functions, Create a program that has a “Shrink” function that takes an integer and returns the integer divided by two. (Hint: your returned value should most likely be of the double type.) Screen captures of the new code being executed can help you with your experimentation.

Include stdio.h> in your code.

/ Prototypes of functions

integer Shrink(int value); integer Main ()

/* variable definition: */ int intValue, menuSelect, Results; intValue = 1; / Whereas a positive integer is present, while (intValue greater than 0)

{ printf (””Enter a positive Integer\n: ””); scanf(””%d””, &intValue); if (intValue > 0)

{ printf (””Enter 1 to calculate Shrink\n: ””); scanf(””%d“”, &menuSelect); if (menuSelect == 1)

{// Call the Square Function

Results = Shrink(intValue);

printf(”Shrink of %d is %d\n”,intValue,Results);

}

}

return 0;

}

}

/* function returning the Shrink of a number */

int Shrink(int value)

{

return value/2;

}

 

Prepare a new test table with at least 3 distinct test cases listing input and expected output for the code you created after step 1.

Test Case #

Value

Expected outcome

1

8

4

2

14

7

3

16

8

Test case 1

Test case 2

Test Case 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.

Removing the code if intValue > 0 would result in the program giving an output for negative value but only for one time. The explanation to this would be because after all calculations once the loop is checked the negative value will make the condition false therefore the control will exit the loop.

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.

Test Case

Value

Expected outcome

1

3

1.442

2

5

1.7099

3

6

1.8177

April 13, 2023
Number of pages

2

Number of words

311

Downloads:

49

Writer #

Rate:

4.7

Expertise Value
Verified writer

Richard is the best writer for Data Science tasks, even if you have something really complex. I needed to do tasks on security matters and already had a draft. Sharing my ideas with Richard ended up in a perfect paper!

Hire Writer

Use this essay example as a template for assignments, a source of information, and to borrow arguments and ideas for your paper. Remember, it is publicly available to other students and search engines, so direct copying may result in plagiarism.

Eliminate the stress of research and writing!

Hire one of our experts to create a completely original paper even in 3 hours!

Hire a Pro