The while statement is also a looping statement. the while loop evaluates the test expression before every loop, so it can execute zero times if the condition is initially false
Syntax:while (expression)
{
statement 1;
statement 2;
â¦â¦â¦â¦...
statement n;
}
Example:#include
int main(){
int number,factorial;
printf("Enter a number.\n");
scanf("%d",&number);
factorial=1;
while (number>0){ /* while loop continues util test condition number>0 is true */
factorial=factorial*number;
--number;
}
printf("Factorial=%d",factorial);
return 0;
}
Output
Enter a number.
5
Factorial=120
License.
All information of this service is derived from the free sources and is provided solely in the form of quotations.
This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 518 / 158776821. Delta: 0.02849 с