#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int dig(int n, int *a);
revnum(int m, int *a);
int n,m;
void main()
{
int x[10], *a=&x[0], newno;
clrscr();
printf("Enter the number:");
scanf("%d", &n);
m=dig(n, a);
newno=revnum(m,a);
printf("\nReverse of the given number %d= %d",n,newno);
if(n==newno)
printf("\n\nEntered number and reverse number are same");
else
printf("\n\nEntered number and reverse number are not same");
getch();
}
int dig(int n, int *a)
{
int i=0, y;
while(n>0)
{
y=n%10;
*(a+i)=y;
n=n/10;
i++;
}
return i;
}
revnum(int m, int *a)
{
int z=0, s=0, d=m;
for(z=0; z<m; ++z, d--)
s=s+*(a+z)* pow(10, d-1);
return s;
}
#include<stdlib.h>
#include<math.h>
int dig(int n, int *a);
revnum(int m, int *a);
int n,m;
void main()
{
int x[10], *a=&x[0], newno;
clrscr();
printf("Enter the number:");
scanf("%d", &n);
m=dig(n, a);
newno=revnum(m,a);
printf("\nReverse of the given number %d= %d",n,newno);
if(n==newno)
printf("\n\nEntered number and reverse number are same");
else
printf("\n\nEntered number and reverse number are not same");
getch();
}
int dig(int n, int *a)
{
int i=0, y;
while(n>0)
{
y=n%10;
*(a+i)=y;
n=n/10;
i++;
}
return i;
}
revnum(int m, int *a)
{
int z=0, s=0, d=m;
for(z=0; z<m; ++z, d--)
s=s+*(a+z)* pow(10, d-1);
return s;
}
No comments:
Post a Comment