C - Write program to display values from -5 through 5, using an increment of 0.5.

Requirements

Write a program that uses a while loop to display values from -5 through 5, using an increment of 0.5.

Demo

#include <stdio.h>

int main()/*from w w w  .  j a  v  a2 s  . c  o  m*/
{
    float halfstep;

    halfstep = -5.0;
    while(halfstep <= 5.0)
    {
        printf("%f\n",halfstep);
        halfstep = halfstep + 0.5;
    }
    return(0);
}

Result

Related Exercise