C - Write program to displays values from -10 to 10 and then back down to -10 using while loop

Requirements

Construct a program that displays values from -10 to 10 and then back down to -10.

Demo

#include <stdio.h>

int main()/*from  w  ww .j ava 2 s .c om*/
{
    int d;

    d = -10;
    while(d<10)
    {
        printf("%d ",d);
        d++;
    }
    while(d>=-10)
    {
        printf("%d ",d);
        d--;
    }
    putchar('\n');
    return(0);
}

Result

Related Exercise