Computer Science, asked by Sam071, 1 year ago

write a program in c which takes four digit number as input and print its reverse

Answers

Answered by aksachan6121
3
hii dear .......
#include<stdio.h>
int main()
{
int num,reverse_number; //User would input the number
   printf("\nEnter any number:");
    scanf("%d",&num); //Calling user defined function to perform reverse reverse_number=reverse_function(num);
    printf("\nAfter reverse the no is :%d",reverse_number);
return 0;
}
int sum=0,rem;
 reverse_function(int num){ if(num){ rem=num%10;
       sum=sum*10+rem; reverse_function(num/10);
}
else return sum;
return sum;
}


salonisingh160oztp48: Lag to kuch vaisa hi rha hai jo hum answer diye hai , ab pta nhi , acha hai.......
salonisingh160oztp48: :)
Answered by salonisingh160oztp48
0
I think the answer which I'm going to tell is wrong but I would try my best!

It's a program to display the reverse of a number. For example if you enter 243, the output of the program should be 342.

REM DISPLAYING THE REVERSE OF A NUMBER
CLS
REV =0
INPUT "ENTER THE. NUMBER", N
DO WHILE N. > 0
DIGIT =. N MOD. 10
REV = REV *. 10. + DIGIT
N =. N \ 10
LOOP
PRINT. " THE REVERSE. NUMBER
IS: " , REV
END

This program uses the same concept as the degit extraction program. Here the new number is formed by the statement, REV =. REV * 10 + DIGIT .

I don't think it would be helpful............
Sorry , I just wanted to try........
Similar questions