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