bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_1 / practice-c / pc010.c

pc010.c (412B)


      1 /* Reverse a number */
      2 
      3 #include <stdio.h>
      4 int main()
      5 {
      6     int num, temp, rev = 0;
      7     printf("\nEnter the number : ");
      8     if (scanf("%d", &num) != 1)
      9     {
     10         printf("\nOnly a number is allowed.");
     11         return 1;
     12     }
     13     temp = num;
     14     while (temp > 0)
     15     {
     16         rev = (rev * 10) + (temp % 10);
     17         temp /= 10;
     18     }
     19     printf("\nReverse of the number %d : %d", num, rev);
     20     return 0;
     21 }