Computer Science, asked by 6Shivam92, 1 year ago

Wap to accept a number and reverse it. using If, else

Answers

Answered by siddhant39
1
Example: Reverse an Integer

#include <stdio.h> int main() { int n, reversedNumber = 0, remainder; printf("Enter an integer: "); scanf("%d", &n); while(n != 0) { remainder = n%10; reversedNumber = reversedNumber*10 + remainder; n /= 10; } printf("Reversed Number = %d", reversedNumber); return 0; }

Answered by siddhartharao77
0
int a,b;

printf("Enter a number");
scanf("%d",&a);

b = c(b);
printf("The reverse of this number : %d", b);
return 0;
}

int c(int b)
{
static d,e;

if(b)
{
e = b%10;
d = d * 10 + e;
c(b/10);
}
else
return 0;

return d;
}

Hope this helps!
Similar questions