vendredi 18 février 2022

can anyone help me how do i change a while loop into a for loop like this,does the whole code gets change?

how do I change a while loop into a for loop like this

  #include <stdio.h>

 int main() 
{

 int number; long int factorial;
 factorial=1;
 printf("\nEnter the number:");
 scanf("%d",&number);
 do{
    factorial = factorial * number--;
}while(number > 1);
printf("\nThe factorial is %d",factorial);

}

Aucun commentaire:

Enregistrer un commentaire