Follow This Blog For more... 😊

Program to accept a number and print that number in reverse order.| Using C language| C Program series 18|

👨‍💻Program to accept a number and print that number in reverse order.

Code:


    //Program to accept a number and print that number in reverse order.
    #include<stdio.h>
    main()
    {
        printf("Program to accept a number and print that number in reverse order.\n\n");
       
        int n,r;
        /*Where,
        n=number
        r=remainder
        */
        printf("Enter the number:");
        scanf("%d",&n);
        printf("\nGIVEN ORDER:%d\n",n);
        printf("REVERSE ORDER:");
        while(n>0)
        {
            r=n%10;
            printf("%d",r);//it prints remainder one by one and its order is reverse.
            n=n/10;
        }
    }

Output:




👉Click for more C Program series Questions.[Questions list]

Comments

Popular Posts