Link to home
Start Free TrialLog in
Avatar of lhutton
lhutton

asked on

Simple C Program

I'm trying to write a program to print a conversion table from 0 to 100 celsius (in intervals of 5) to fahrenheit in this format. I have the following but can't get the intervals to increase by 5.

#include <stdio.h>

int main(void)
{
  float C=0,F;
  int i;
  printf("Celsius | Fahrenheit\n");
  printf("========|===========\n");
  for (i=0; i<=100; i=i+5)
  {
    F=9*C/5+32;
    printf("%5.0f   |%7.0f    \n",C,F);
    C=5;
  }
  return 0;
}
Avatar of ozo
ozo
Flag of United States of America image

You've got i to increase by 5, do you want to do anything with i?
What do you want to increase by 5?
ASKER CERTIFIED SOLUTION
Avatar of jpjpjp
jpjpjp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lhutton
lhutton

ASKER

I need celsius to increase by 5, so I get a table like:

Celsius | Fahrenheit
======|=========
    0       |     32
    5       |     ..
   10      |     ..
  100     |    212
Avatar of lhutton

ASKER

Perfect! Thanks :) My confusion was with using i instead of C.