Friday, February 1, 2013

C Language Example # 15 Loop Example : Display Reverse Number of the given integer number.


C Language Example # 15   Loop Example : Display Reverse Number of the given integer number..


Lets now starts with Looping Structure of C Programming Language.


C Language Code Sample 1


//Written by Latest Technology Guide    
//Title : Example  15   Loop Example : Display Reverse Number of the given integer number..
  
#include <stdio.h>
#include <conio.h>



void main()
{
clrscr();
int user_number,answer,digit;

printf("Enter Number :");
scanf("%d",&user_number);

printf("\n Answer is : ");

while(user_number>0)
{
digit=user_number%10;
printf("%d",digit);
user_number=user_number/10;
}

getch();
}

Output:
We think there is no need of Output for this program.

=================================================================


C Language Code Sample 2

//Written by Latest Technology Guide    
//Title : Example  15   Loop Example : Display Reverse Number of the given integer number..
  
#include <stdio.h>
#include <conio.h>



void main()
{
clrscr();
int user_number,answer,digit,i=1;

printf(" Enter Number :");
scanf("%d",&user_number);

printf("\n Answer is : ");

while(user_number>0)
{
digit=user_number%10;
i = i *10;
answer=(answer * i) + digit;
user_number=user_number/10;
}

printf("%d",answer);
getch();
}


Output:
We think there is no need of Output for this program.


--------------------------------------------------------------------------------
Explanation of C Language Example  # 15  Loop Example : Display Reverse Number of the given integer number..

* Enter Number you want to find reverse value .
* This C Program will convert it into reverse.

Still having doubts you can post comment, will explain in details.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

No comments:

Post a Comment