may inplease get help? I am stuck for a while and i want to make sure the direct
ID: 3691472 • Letter: M
Question
may inplease get help? I am stuck for a while and i want to make sure the direction that i code is correct. could you please help me with sample code and comments of explanations? thanks!!
Explanation / Answer
#include <stdio.h>
void celsius_to_fahrenheit(int *c ,int *f){
*f = ((*c * 9)/5) + 32;
}
void pounds_to_kilogram(float *p ,float *kg){
*kg = *p * 0.45359237;
}
void feet_to_kilometer(double *ft ,double *km){
*km = *ft * 0.0003048;
}
int main(void) {
// your code goes here
int c,f;
float p,kg;
double ft,km;
int ch;
printf("Choose a conversion from below by typing corresponding number: ");
printf("1.celsius to fahrenheit ");
printf("2.Pounds to kilogram ");
printf("3.feet to kilometer ");
scanf("%d",&ch);
switch(ch){
case 1 :printf(" Enter Celisus value:");scanf("%d",&c);celsius_to_fahrenheit(&c,&f);printf(" celisus=%d fahrenheit=%d",c,f); break;
case 2: printf(" Enter Pounds:");scanf("%f",&p);pounds_to_kilogram(&p,&kg);printf(" Pounds=%.2f Kilogram=%.2f",p,kg); break;
case 3:printf(" Enter feet:");scanf("%lf",&ft);feet_to_kilometer(&ft,&km);printf(" feet=%lf kilometer=%lf",ft,km); break;
default:printf("Invalid selection");break;
}
return 0;
}
Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.