#include<conio.h>
#include<stdio.h>
void main()
{
int num,n,a,loc=0,count=0,c;
clrscr();
// Entering the number
printf("\nEnter the number: ");
scanf("%d",&num);
// Entering the digit to find
printf("\nEnter the digit to find: ");
scanf("%d",&a);
// Logic starts
while(num>0)
{
n=num%10;
num=num/10;
count++;
if(a==n)
{
printf("\nDigit found at: ");
loc=count;
}
}
// Printing the position
if(loc==0)
{
printf("\n\n Item not found.");
}
else
{
printf("%d location.",(count-loc+1));
}
getch();
}
#include<stdio.h>
void main()
{
int num,n,a,loc=0,count=0,c;
clrscr();
// Entering the number
printf("\nEnter the number: ");
scanf("%d",&num);
// Entering the digit to find
printf("\nEnter the digit to find: ");
scanf("%d",&a);
// Logic starts
while(num>0)
{
n=num%10;
num=num/10;
count++;
if(a==n)
{
printf("\nDigit found at: ");
loc=count;
}
}
// Printing the position
if(loc==0)
{
printf("\n\n Item not found.");
}
else
{
printf("%d location.",(count-loc+1));
}
getch();
}
No comments:
Post a Comment