Use the decrement operator to count down instead of up - C Statement

C examples for Statement:for

Description

Use the decrement operator to count down instead of up

Demo Code


#include <stdio.h>
int main(void)
{
    int secs;/* w ww. j av a2 s .  co m*/
    
    for (secs = 5; secs > 0; secs--)
        printf("%d seconds!\n", secs);
    printf("from book 2s.com!\n");
    return 0;
}

Result


Related Tutorials