program to reverse the number by using pointer in c-programming
In this program ,we will now takes input as a number and print the reverse of the number by using pointer in c-programming.
//program to reverse of the number by using pointer
#include<stdio.h>
#include<conio.h>
void main()
{
int n,rev,num;
int *n1,*rev1,*num1;
n1=&n,rev1=&rev,num1=#
*num1=0;
printf("enter the number:-");
scanf("%d",&n);
while(*n1!=0){
*rev1=*n1%10;
*num1=*num1*10+*rev1;
*n1=*n1/10;
}
printf("\n the reverse of the number is %d",*num1);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,rev,num;
int *n1,*rev1,*num1;
n1=&n,rev1=&rev,num1=#
*num1=0;
printf("enter the number:-");
scanf("%d",&n);
while(*n1!=0){
*rev1=*n1%10;
*num1=*num1*10+*rev1;
*n1=*n1/10;
}
printf("\n the reverse of the number is %d",*num1);
getch();
}
output:
For more c-programming:-

No comments:
Post a Comment