program to reverse the digits


small programs troubles a lot ,if you know the basic then you are on a safer side otherwise you would be sucked in a midway.

don't think so , I am telling you on the basis of experience if you don't believe try this program first without seeing the program and tell me in a comment about what happened.

if you are able to make the desired program then congo you are a good and hardworking developer.

who are not don't worry you are also on right track if you are going through c4fun on regular basis then you are going to have the most basic program with the very simple logic which is very easy to understand and grab by the students.


please note that try to make a program by your self  first so that you can build a confidence if you are not able to do then move on to the solution or source code which is given below.

so below c4fun brings you the program to reverse the number
the number can be taken as input from the user and reverse can be printed as desired output.

C4fun brings a  program to reverse a number: 

#in this program the number is entered by the user  which can be any numbers of digits like 
3 digit or 4 digits .depanding upon the user choice.
 reverses  number entered  and then print it 

 For example,
 if a user enters 456 as input then 654 will be printed as output.
different examples can be taken to understand easily , the concept is very simple and easy behind it.   we use modulus (%) operator to obtain the digits of a number. 


source below is given below, go through it...


#include<stdio.h>
#include<conio.h>
void main()
{
int n,d,r=0,m;
clrscr();
printf("enter the number\n");
scanf("%d",&n);
m=n;
while(m>0)
{
d=m%10;
r=r*10+d;
m=m/10;
}
printf("reverse of %d=%d",n,r);
getch();
}

the output which is obtained as an result is displayed by the program, depending upon the input the output will vary and thus we are able to get different numbers of the result .
the while loop in the program is running till it is greater than zero as soon as the condition becomes false the loop is terminated and the result is obtained


 To reverse  large numbers use long data type 

print different number and see the reverse of them, by choosing them randomly and comment the original number along with the reverse you got.....



comment down the results you have obtained and do share the blog and source code among your friends whom you might think would help them to find and make the simple program a little bit of tough.
as sharing is caring this sharing of content might help you and your friend score marks or might build some confidence as he has done simple programming which earlier he was not able to do.

also visit travel places to see the places which you would love

No comments

thanks for reading and sharing.I hope it would help you!!!!

Powered by Blogger.