explain the while statement with an example
if you answer correctly I can choose you as a brainiest......
Answers
Answered by
0
Answer:
The while statement allows you to repeatedly execute a block of statements as long as a condition is true. A while statement is an example of what is called a looping statement. A while statement can have an optional else clause.
Explanation:
Make me Brainliest
Follow me
Thank me
Answered by
0
Answer:
- The while statement allows you to repeatedly execute a block of statements as long as a condition is true. A while statement is an example of what is called a looping statement. A while statement can have an optional else clause.
- In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of as a repeating if statement.
Example:
// Print numbers from 1 to 5
#include <stdio.h>
int main()
{
int i = 1;
while (i <= 5)
{
printf("%d\n", i);
++i;
}
return 0;
}
Output:
1
2
3
4
5
I hope this would help you out.. ☺️
Attachments:
Similar questions