While loop in c

while can be used as a infinite loop too ,the while loop executes the statements if the test condition is true. This process continues until the test condition fails(false).lest look into the while loop syntax

syntax:

while(test condition)
{
statements(s);
}

here, as long as the condition is satisfied the statements between the braces are executed, let’s look into a program for factorial and flow chart of while loop. We can use increment and decrement statements inside the while loop

flowchart:

while in c
#include
void main()
{
int number;
long long factorial;
printf("Enter an integer: ");
scanf("%d",&number);
factorial = 1;
while (number > 0)
{
factorial *= number; // factorial = factorial*number;
--number;
}
printf("Factorial= %lld", factorial);
}

output:

Enter an integer: 5
Factorial= 120