c program for the reverse the digits

后端 未结 8 938
北恋
北恋 2021-01-07 11:27

I am looking for the C program for reverse the digits like below:

If i enter:

123456

Then the result would

8条回答
  •  执念已碎
    2021-01-07 12:02

    1. count the number of digits in number and store in count variable
    2. extract individual digits in variable
    3. use the power function.

      while(count>=1)
      {
        var = num % 10;
        sum = sum + var * pow(10, count - 1);
        num =num / 10;
        count--;
      }
      

提交回复
热议问题