/* To find the no. of digits in the given integer */
#include<stdio.h>
#include<conio.h>
main()
{
int x,i=0,a[10],k;
long n;
clrscr();
printf("\n enter an integer :");
scanf("%ld",&n);
while(n>0)
{
x=n%10;
a[i]=x;
n=n/10;
if(a[i]==0)
break;
else
i++;
}
printf("\n The number of digits in the given number are:%d",i);
printf("\n And the numbers are:");
for(k=i-1;k>=0;k--)
printf("\n%d",a[k]);
getch();
}
#include<stdio.h>
#include<conio.h>
main()
{
int x,i=0,a[10],k;
long n;
clrscr();
printf("\n enter an integer :");
scanf("%ld",&n);
while(n>0)
{
x=n%10;
a[i]=x;
n=n/10;
if(a[i]==0)
break;
else
i++;
}
printf("\n The number of digits in the given number are:%d",i);
printf("\n And the numbers are:");
for(k=i-1;k>=0;k--)
printf("\n%d",a[k]);
getch();
}
No comments:
Post a Comment