The online math course provider "MathAtTip'
has designed a course for children called
Learning Number Recognition and Counting.
The assessment part of the course has a
question where the student is given a number
and a digit. The student needs to find out the
total count of the digits present in the number
excluding the given digit.
Write an algorithm to help the student find out
the count of the total number of digits present
in the number excluding the given digit.
Input
The input consists of two space separated
integers - number and digit where the first
integer represents the number and the second
integer represents the digit given to the
student.
Answers
Answered by
16
Answer:
#include<stdio.h>
int main()
{
int num,n,count=0,rem=0;
printf("enter a number");
scanf("%d",&num);
printf("enter a digit");
scanf("%d",&n);
// printf("%d %d",num,n);
while(num!=0)
{
rem = num % 10;
if(rem!=n)
{count++;
}
num = num / 10;
}
printf("%d",count);
}
Explanation:
Similar questions