In Microsoft Visual Studios: Write a C program that evaluates the equations prov
ID: 3663798 • Letter: I
Question
In Microsoft Visual Studios:
Write a C program that evaluates the equations provided below. The program must prompt the user for inputs to the equations and evaluate them based on the inputs. All variables on the right hand sides of the equations must be inputted by the user. All variables, except for the plaintext_character, encoded_character, and variable a are floating-point values. The plaintext_character and encoded_character variables are characters, and the a variable is an integer. The constants used in the equations must be defined as constant macros (#defined constants). Error checking is not required for your program. You do not need to check for faulty user input or dividing by zero.
result should be simiar to this:
Explanation / Answer
See the code below:
------------------------------------------------------------
/*
This program evaluates the equations for Newton's Second Law and Cylinder's Volume.
*/
#include <stdio.h>
#include <stdlib.h>
//PI constant
#define PI 3.141592
//main function()
int main(void) {
float mass, acceleration, force; //for use in Newton's second law
float radius, height, volume_cylinder; //for use in cylinder's volume equation
//Newton's Second Law
printf("Please enter the mass and acceleration (both floating-point values) for use in Newton's Second Law:");
scanf("%f %f",&mass, &acceleration);
force = mass*acceleration;
printf("Newton's Second Law: force = mass*acceleration = %f * %f = %f ",mass,acceleration,force);
//Cylinder's volume equation
printf("Please enter the radius and height (both floating-point values) for use in a volume of cylinder equation:");
scanf("%f %f", &radius, &height);
volume_cylinder=PI*radius*radius*height;
printf("Volume of a cylinder: volume_cylinder = PI * radius^2 * height = 3.141592 * %f^2 * %f = %f",radius,height,volume_cylinder);
return EXIT_SUCCESS;
}
------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.