Basic C programming.. logical error while converting Celsius to kelvin -
this question has answer here:
- c: converting farenheit celsius 3 answers
#include <stdio.h> #include <stdlib.h> int main(void) { int celsius = 0, kelvin = 0; float farenheit; printf("enter boiling of water in celcius \n"); scanf("%d", &celsius); kelvin = 273 + celsius; farenheit = celsius * (9 / 5) + 32; printf("the boiling point of water in kelvin %d \n , in farenheit %f \n \n", kelvin, farenheit); printf("enter freezing point of water in celcius \n"); scanf("%d", &celsius); kelvin = 273 + celsius; farenheit = celsius * (9 / 5) + 32; printf("the freezing point of water in kelvin %d \n , in farenheit %f \n \n", kelvin, farenheit); return 0; }
in eclipse, type code , i'm expecting ask me on console "enter boiling of water in celsius" , wait till type in 100 , again same freezing point. after build(ctrl+b), nothing. had enter number(here did '100')then press 'enter' , again number (here '1') press 'enter'. displayed me calculations '100' degree celsius.and didn't ask me enter freezing point either. typed '1' , pressed enter. whats wrong code.?
here's output.
100 1 enter boiling of water in celcius boiling point of water in kelvin 373 , in farenheit 132.000000 enter freezing point of water in celcius freezing point of water in kelvin 274 , in farenheit 33.000000
int celsius; scanf("%d", &celsius); int kelvin = 273 + celsius; float farenheit = 1.8 * celsius + 32; // make float
input
100 0
output
212.000000 373 32.000000 273
see http://ideone.com/6ikg23 demo.
Comments
Post a Comment