Hi,
I am pretty new in c programming, I started wrting codes but am having trouble finding the error in this one. can any help me
Code:
#include <stdio.h>
void numberof(int);
int main(void)
{
int num;
printf("Enter the number:");
scanf("%d",&num);
if (num>=1000000 || num <=9999)
printf("Too big");
else
numberof(num);
}
void numberof(int number)
{
int i;
int digits; // number of sevens
int result =(number%10)/7;
for(i =1; i <6;i++)
{
if(result == 1)
digits++;
number/10;
}
printf("%d, digits", digits);
}
The problem is to find the number of sevens in the user inputed 5-digit number.
But the problem in the output is that
if the user types any number with 7 in it..that is 28517 or 27752 ..its always showing as 5 sevens.
I am having trouble in finding the problem . Any help is appreciated. Thanking in advance