Code:
#include <stdio.h>#include <stdlib.h>
float Konversi(char x,float y,char z){
float hasil;
if(x=='C' && z=='K'){
hasil=y+273;}
else if(x=='C' && z=='F'){
hasil=((9.0/5.0)*y)+32;}
else if(x=='C' && z=='R'){
hasil=(4.0/5.0)*y;}
else if(x=='R' && z=='C'){
hasil=(5.0/4.0)*y;}
else if(x=='R' && z=='F'){
hasil=((9.0/4.0)*y)+32;}
else if(x=='R' && z=='K'){
hasil=((5.0/4.0)*y)+273;}
else if(x=='F' && z=='C'){
hasil=(5.0/9.0)*(y-32);}
else if(x=='F' && z=='C'){
hasil=(4.0/9.0)*(y-32);}
else if(x=='F' && z=='K'){
hasil=((5.0/9.0)*(y-32))+273;}
else if(x=='K' && z=='C'){
hasil=y-273;}
else if(x=='K' && z=='R'){
hasil=(4.0/5.0)*(y-273);}
else if(x=='K' && z=='F'){
hasil=((9.0/5.0)*(y-273))+32;}
else{
printf("%c",x);
hasil=0;
}
return hasil;
}
int main()
{
char x,z;
float y;
scanf("%f",&y);
scanf("%c",&x);
scanf("%c",&z);
printf("%f",Konversi(x,y,z));
}
Now input stop after second input.
Originally Posted by
Matticus
I will not provide a complete solution - that would take away a valuable learning experience, and goes against the
homework policy.
You said you tried to apply the advice I gave - you should post your updated code, along with any specific problems you're having. If you have any questions on anything I posted, just ask.
You can do this. Give it your best shot and we'll help you along.