Tuesday 20 November 2012

C program code for reverse number using function with while loop


how to write code to reverse given number in c program using function with comments
#include<stdio.h>  //including header files
#include<conio.h>
long int reverse(long int); // declaring function with parameter
void main()    // start main
{
 long int n;
 clrscr();
 printf("enter the value \n"); // asking for enter the value
 scanf("%ld",&n); // taking value from user
 printf("result=%ld",reverse(n));  //calling function
 getch();
 }
long int reverse(long int a)  // intialization of function
{
 int r;
 long int s=0;
 while (a != 0)  // checking number will not zero
 {
  r=a%10;    
  s=10*(s+r);
  a=a/10;
  reverse(a);  // reversing number
  }
 return (s/10); //returning reversed number
 }
c programming example  for reverse number using function with  while loop
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: