do while loop -
In most computer programming languages, a do while loop, sometimes just called a do loop, is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.
Syntax –
do {
statements;
} while (condition);
Example -
#include
int main(void)
{
int value, r_digit;
printf(“Enter a number to be reversed.\n”);
scanf(“%d”, &value);
do
{
r_digit = value % 10;
printf(“%d”, r_digit);
value = value / 10;
} while (value != 0);
printf(“\n”);
return 0;
}
Out Put –
Enter the number to be reversed.
123456 -
654321
No comments:
Post a Comment