-->
Showing posts with label program to get reverse of a number using function. Show all posts
Showing posts with label program to get reverse of a number using function. Show all posts

program to get reverse of a number using function


using codeblocks
--------------------------------------------------------------

//program to get reverse of a number using function

#include<stdio.h>                      //header file
void reverse();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
reverse();                                     // function calling.
return 0;                                       //returns 0 value
}
void reverse()                              // function body line ; also called function definition
{
int rem;                             //initialization to value 1
 int n;                                       // variable declaration
 printf("enter a number\n");
 scanf("%d",&n);                            //input
for(;n!=0;)                     //loop running from 1 to 100 with increment 1 each time
{
    rem=n%10;               //finding remainder
    printf("%d",rem);       //output
    n=n/10;                 //finding next integer number and trasnforming that into 'n'
}
   

}
------------------------------------------------------------------------------------------------------

using turboc++
--------------------------------------------------------------------------------------------------
//program to get reverse of a number using function
#include<stdio.h>                      //header file
#include<conio.h>
void reverse();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
reverse();                                     // function calling.
getch();                                       //holds the output.
}
void reverse()                              // function body line ; also called function definition
{
int rem;                             
 int n;                                       // variable declaration
 printf("enter a number\n");
 scanf("%d",&n);                            //input
for(;n!=0;)                     //loop running until its value reaches 0 each time
{
    rem=n%10;               //finding remainder
    printf("%d",rem);       //output
    n=n/10;                 //finding next integer number and trasnforming that into 'n'
}
   

}