Write a C program that reverses a number that is entered by the user by making use of do-while loop. How is this looping technique different from while loop?
Answers
Answered by
4
C Program to reverse digits of a number using do while loop
#include<stdio.h>
#include<conio.h>
void main()
{
int num;
int rev=0, rem=0;
printf("\n Enter a number: ");
scanf("%d",&num);
do
{
rem = num%10;
rev = rev*10+rem;
num = num/10;
}while(num>0);
printf("\n reverse number = %d",rev);
getch();
}
repeat loop will execute at least one iteration whereas while loop may not execute one iteration also if the condition is not fulfilled
Similar questions
Math,
6 months ago
Math,
6 months ago
Computer Science,
1 year ago
Biology,
1 year ago
Geography,
1 year ago