#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,m,sum=0,a;
int i;
printf("Enter a no");
scanf("%d",&n);
printf("Enter position on which you want to find digit from left");
scanf("%d",&a);
m=n;
while(n>0)
{
sum++;
n=n/10;
}
if(a!=sum)
{
n=m/(pow(10,sum-a));
n=n%10;
}
else
{
n=m%10;
}
printf("Digit that you want is %d",n);
getch();
}
output
Enter a no 4353
Enter position on which you want to find digit from left 4
Digit that you want is 3
No comments:
Post a Comment