C - Use decrementing operator in for loop statement

Introduction

The ++ operator's opposite is the decrementing operator --, which is two minus signs.

This operator decreases the value of a variable by 1; for example: var--;

The preceding statement is the same as

var=var-1; 

Demo

#include <stdio.h>

int main()/*  w ww .j av  a 2s.c  o m*/
{
    int c;

    for(c=-5;c<5;c++)
        printf("%d ",c);
    for(;c>=-5;c--)
        printf("%d ",c);
    putchar('\n');
    return(0);
}

Result

Related Topic