For and while loop can be used anywhere in replace of do-while then why the C language has do-while loop, what is it's real use .
#include <stdio.h>
int main()
{
do{
statements;
}
while(condition);
}
return 0;
For and while loop can be used anywhere in replace of do-while then why the C language has do-while loop, what is it's real use .
#include <stdio.h>
int main()
{
do{
statements;
}
while(condition);
}
return 0;
The main use of using a do while loop is that even if the condition that you pass is false it will execute the loop at least once.
While Loop: First condition then execute the code
Do While Loop: First execute the code then condition