REercise 01: Cmaking decision fumotions) Develop a C function that reads three i
ID: 3806024 • Letter: R
Question
REercise 01: Cmaking decision fumotions) Develop a C function that reads three integers. The function should print the min value among these three inputs Develop a C function that reads two integers (x and.y and one floating-point value (zin that zis an angle value in degree). The function should print the result from the following equation (with 2 decimal point format (i.e. 12.34 hint: apply %.2f Write a C program that chooses an option value (1,2 or 3D. The action prompted by the chosen option as follows and performs only once for each running: Option 1: Call function 1 Option 2: Call function 2 Option 3: Print the message "No function was called Output exam Garst running) Enter an option: Enter three integers: 192611 Min value: 11 (second running) Enter an option: Enter two integers and one floating value: A 3376 third running) Enter an option: 3 No function was calledExplanation / Answer
#include <stdio.h>
#include <math.h>
void displayMin() {
int a,b,c, min;
printf("Enter three integers: ");
scanf("%d %d %d", &a, &b, &c);
if( a<= b && a<=c){
min = a;
}
else if( b <= c){
min = b;
}
else{
min = c;
}
printf("Min value is %d ", min);
}
void calculate() {
int x,y;
double z,f;
printf("Enter two integers and one floating value: ");
scanf("%d %d %lf", &x, &y,&z);
f = pow(x,2)+pow(y,3)+4 * sin(z);
printf("f(x,y,z) = %lf ",f);
}
int main()
{
int option;
do{
printf("Enter an option: ");
scanf("%d", &option);
switch (option) {
case 1: displayMin(); break;
case 2: calculate(); break;
case 3: printf("No function was called "); break;
}
} while(option<3);
return 0;
}
Output:
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
Enter an option: 1
Enter three integers: 19 26 11
Min value is 11
Enter an option: 2
Enter two integers and one floating value: 4 3 37.6
f(x,y,z) = 42.604201
Enter an option: 3
No function was called
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.