Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

So I have this code here, and i am trying to make it so that if you

So I have this code here, and i am trying to make it so that if you

input anything besides the given letter inputs, it says “invalid selection” however it is not working. Is the squiggly bracket in the wrong place? Do I put the invalid selection somewhere else in the code?

#include <stdio.h>
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);

// end function menu
else
{printf(“Invalid Selection \n”);} //If you do not select a valid letter this message will display
return 0;
}
int main() {
while (menu() == 0);
printf (“… bye …\n”);
return 0;
} // end main

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"