Modify the original code and add an additional function of your choice. The function should be...

70.2K

Verified Solution

Question

Programming

Modify the original code and add an additional function of yourchoice. The function should be unique and something you created forthis assignment. Support your experimentation with screen capturesof executing the new code. Prepare a test table with at least 3distinct test cases listing input and expected output for yourunique function.

#include

void printHelp () {

printf (\"\n\");

printf (\"a: a(x) = x*x\n\");

printf (\"b: b(x) = x*x*x\n\");

printf (\"c: c(x) = x^2 + 2*x + 7\n\");

printf (\"q: quit\n\");

}

void a(float x) {

float v = x*x;

printf (\" a(%.2f) = %.2f^2 = %.2f\n\", x, x, v);

} // end function a

void b(float x) {

float v = x*x*x;

printf (\" b(%.2f) = %.2f^3 = %.2f\n\", x, x, v);

} // end function b

void c(float x) {

float v = x*x + 2*x + 7;

printf (\" c(%.2f) = %.2f^2 + 2*%.2f + 7 = %.2f\n\",

x, x, x, v);

} // end function c

int menu () {

char selection;

float x;

printHelp ();

scanf (\"%s\", &selection);

if (selection == 'q') return 1;

scanf (\"%f\", &x);

if (selection == 'a') a(x);

if (selection == 'b') b(x);

if (selection == 'c') c(x);

return 0;

} // end function menu

int main() {

while (menu() == 0);

printf (\"... bye ...\n\");

return 0;

} // end main

Answer & Explanation Solved by verified expert
3.9 Ratings (428 Votes)
include void printHelp printf nprintf a ax xxnprintf b bx xxxnprintf c cx x2 2x 7nprintf d cx 2x2 2xnprintf q quitnvoid afloat x float v xxprintf a2f 2f2 2fn x x v end function avoid bfloat x float v    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students