Forums Programming Assignment Help Write a c program to reverse a given number.

This topic contains 1 reply, has 2 voices, and was last updated by  juwanine 5 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15180

    ahprofessional
    Participant

    Write a c program to reverse a given number.

    #15186

    juwanine
    Participant

    Ans:

    #include<stdio.h>
    int main(){
    int num,r,reverse=0;

    printf(“Enter any number: “);
    scanf(“%d”,&num);

    while(num){
    r=num%10;
    reverse=reverse*10+r;
    num=num/10;
    }

    printf(“Reversed of number: %d”,reverse);
    return 0;
    }

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.