In: Computer Science
All program should be in C
Write its pseudocode and draw its flowchart) to prompt the user to input the variables to solve the following problem:
X2 + X×Y/Z - W*V3
Note 1: You should ask the user to input 5 numbers to be able to do this calculation.
Note 2: You can use multiplication instead of power if you do not want to use it (as we have not officially covered it).
Write a program (compile and run), pseudocode, and draw a flowchart for each of the following problems:
a) Obtain three numbers from the keyboard, compute their product, and display the result.
Ans:
b) Obtain two numbers from the keyboard, and determine and display which (if either) is the smaller of the two numbers.
Ans:
c) Obtain a series of positive numbers from the keyboard, and determine and display their average (with 4 decimal points). Assume that the user types the sentinel value -1 to indicate "end of data entry."
Ans:
running code.
#include <stdio.h>
int main()
{
// first
double x, y, z, w, v;
printf("Enter x, y, z, w, v.\n");
scanf("%lf%lf%lf%lf%lf", &x, &y, &z, &w, &v);
double x2 = x * x;
double v3 = v * v * v;
printf("Answer: %lf\n\n", x2 + x*(y/z) - w*v3);
// second
printf("Enter x, y, z.\n");
scanf("%lf%lf%lf", &x, &y, &z);
double ans = x * y * z;
printf("Answer: %lf\n\n", ans);
// third
printf("Enter x, y.\n");
scanf("%lf%lf", &x, &y);
double min;
if(x < y) {
min = x;
} else {
min = y;
}
printf("Minimum: %lf\n\n", min);
// fourth
printf("Enter series of numbers, -1 to end\n");
double s = 0.0;
int c = 0;
do {
scanf("%lf", &x);
if(x != -1) {
s += x;
c++;
}
} while(x != -1);
printf("Avearage: %lf\n", s/c);
return 0;
}