vendredi 26 août 2016

for Repetition Statement in c

When for statement is executed the value of counter variable has to be increased by one because I use pre-increment operator.

#include <stdio.h>
 int main (void)
 {

     unsigned int counter ;

    for ( counter = 1; counter <= 10; ++counter /*here is problem*/) {
        printf( "%un", counter );
        }
 }

Problem -

When the program is executed, the value of counter variable initially is 1 instead of 2.

Aucun commentaire:

Enregistrer un commentaire