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

Im working on functions in C Programming. I’ve added a new function of “e” All the other functions will work, however my newly input of (void fdunits) will not properly calculate and printf.

Im working on functions in C Programming. I’ve added a new function of “e”

All the other functions will work, however my newly input of (void fdunits) will not properly calculate and printf.

What exactly am I missing?

Below is my code:

#include <stdio.h>

// Protocols for functions beneath main()

void printHelp();

void square(float);

void cube(float);

void parabola(float);

void shrink(float);

void fdunits(float);

int menu();

int main()

{

// While loop calls menu() function

// before test condition

while (menu() == 0);

printf (“… bye …\n”);

return 0;

} // end main

// Function to display menu options to user

int menu()

{

// Define variables only available in this function

char selection;

float flt1;

// Call printHelp() function to display selection options

printHelp ();

 

// Bring in selection from user

scanf (“%s”, &selection);

 

// Check value entered by user

// Call appropriate function when TRUE

if (selection == ‘a’)

{

// Instruct user to enter a float value

// Place that in the flt1 variable

printf(“Enter a float value: “);

scanf (“%f”, &flt1);

 

square(flt1);

}

else if (selection == ‘b’)

{

// Instruct user to enter a float value

// Place that in the flt1 variable

printf(“Enter a float value: “);

scanf (“%f”, &flt1);

 

cube(flt1);

}

else if (selection == ‘c’)

{

// Instruct user to enter a float value

// Place that in the flt1 variable

printf(“Enter a float value: “);

scanf (“%f”, &flt1);

 

parabola(flt1);

}

else if (selection == ‘d’)

{

//Instruct user to enter a float value

printf(“Enter a float value to shrink by 2:”);

scanf (“%f”, &flt1);

shrink(flt1);

}

else if (selection == ‘e’)

{

//Instruct user to enter a float value

printf(“Enter a float value of Kilometers per hour to be converted to Freedom Units:”);

scanf (“%f”, &flt1);

}

// Test for entered value of q from user

// If TRUE, return 1 to main() function

// Ending execution

else if (selection == ‘q’)

{

return 1;

}

// Display message to user if invalid entry

else

{

printf(“Entry must be a, b, c, d or e\n”);

}

return 0;

} // end function menu

void printHelp ()

{

printf (“\n”);

printf (“a: square(x) = x*x\n”);

printf (“b: cube(x) = x*x*x\n”);

printf (“c: parabola(x) = x^2 + 2*x + 7\n”);

printf (“d: shrink(x) = x/2.0\n”);

printf (“e: KPH to Freedom Units(MPH)(x)= x*0.62\n”);

printf (“q: quit\n”);

}

void square(float sqrflt)

{

float result = sqrflt*sqrflt;

printf (” a(%.2f) = %.2f^2 = %.2f\n”, sqrflt, sqrflt, result);

} // end function a

void cube(float cubeflt)

{

float result = cubeflt*cubeflt*cubeflt;

printf (” b(%.2f) = %.2f^3 = %.2f\n”, cubeflt, cubeflt, result);

} // end function b

void parabola(float paraflt)

{

float result = paraflt*paraflt + 2*paraflt + 7;

printf (” c(%.2f) = %.2f^2 + 2*%.2f + 7 = %.2f\n”, paraflt, paraflt, paraflt, result);

}// end fucntion c

void shrink(float xflt)

{

float result = xflt/2.0;

printf (” d(%.2f) = %.2f/2 = %.2f\n”, xflt, xflt,result);

}// end function d

void fdunits(float fdunitsflt)

{

float result = fdunitsflt*.62;

printf (” e(%.2f) = %.2f*0.62 = %.2f\n”, fdunitsflt, fdunitsflt,result);

}// end of function e

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