C program to print reverse of a number using while loop
#includeOutputint main() { int n, rev = 0, remainder; // Integer values printf("Enter an integer: "); // Enter user value scanf("%d", &n); // storing values while (n != 0) // while loop { remainder = n % 10; rev = rev * 10 + remainder; n /= 10; } printf("Reversed number = %d", rev); // finalize result return 0; }
Enter an integer : 2345 Reverse number is 5432Happy Coding
Thanks for visiting my Blog.
Have any problem, feel free to contact us via Email : uoslondy@gmail.com
Have a good day!
0 comments:
Post a Comment