Search C Program | nimishsoft@gmail.com

Reverse number using while loop

/* Reverse number using while loop */

#include<stdio.h>
int main()
{
    int a, s;
    printf("Enter value of a: ");
    scanf("%d",&a);
    s = 0;
    while(a > 0)
    {
        s = s*10;
        s = s + (a%10);
        a = a / 10;
    }
    printf("Reverse number is: %d",s);
    return 0;
}

Related Post:
Reverse number using for loop
http://cbasicprogram.blogspot.in/2012/02/reverse-number-using-for-loop.html

10 comments:

  1. Sir i can't understand your logic,
    why you are use
    "s = s*10;"
    please help me before my exam

    ReplyDelete
    Replies
    1. Nothing the sum value should be assigned and multiplyed with 10

      Delete
    2. Attention everyone, the file provided above is not working. I have been looking for the working file and finally found it.



      ✔️Click Here To Download http://gestyy.com/e0GAyS
      ✔️Click Here To Download

      ✔️Click Here To Download http://exe.io/XONVsO6l

      ✔️Click Here To Download


      ✔️Click Here To Download
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .

      .

      .
      .

      .

      .
      .
      .
      .

      Mn.
      ..

      .
      .
      .
      ..
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      ..
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .cx
      .cx
      .
      .sdcccxxx

      Delete
  2. Write a program that reads N integers, determines how many positive and negative values have been read and computes the total and average of input values

    ReplyDelete
  3. why while loop is use here ?? why for loop not use'

    ReplyDelete
  4. Muhammad Sajid HassanFebruary 23, 2017 at 9:39 AM

    you can do it by for and while loop.even using do while loop.

    ReplyDelete
  5. sir i cant understand how a is printed there??

    ReplyDelete
  6. Please explain the while statement
    s = s*10;
    s = s + (a%10);
    a = a / 10;

    ReplyDelete
  7. There is no any meaning of logic .wrong program

    ReplyDelete