Sunday, July 12, 2009

Using the C language what statement would you use?

Using the C language what statement would you use that will have the program ask for a #, and then use it in the distance formula? (is it scan or a float, or something else)

Using the C language what statement would you use?
double d;





printf("Enter a distance: ");





scanf("%f",%26amp;d);





printf("You entered: %f\n", d);
Reply:If this is a basic intro homework assignment, scanf will work fine. Make sure you use the correct %_ and don't forget to pass your variable into scanf by reference.





Then go ahead and use that variable in the distance formula.


No comments:

Post a Comment