0

I want to repeat the calculative part of the code below: I want t9 repeat the code for the number of times of the digit.....

#include <stdio.h> int main() { int n,i,temp,z=0; printf("enter the number: ",n); scanf("%d",&n); { temp=n/10; temp=n%10; if(temp==0) { z=z+1; } } printf("zeroes= %d",z); return 0; }

29th Apr 2020, 11:52 AM
Dhrumil Sheth
Dhrumil Sheth - avatar
3 ответов
+ 1
Are you trying to count the frequency of digit zero? if that is the case, then you need to use a while-loop. After reading <n> ... while(n) { temp = n % 10; if(temp == 0) z += 1; // same with z = z + 1 n /= 10; // same with n = n / 10 } // print value of <z> here ...
29th Apr 2020, 12:08 PM
Ipang
+ 1
Yes I wanted to do that to count the frequency of zeroes thanks that would help me 👍👌
29th Apr 2020, 12:09 PM
Dhrumil Sheth
Dhrumil Sheth - avatar
+ 1
Alright buddy, happy coding! 👍
29th Apr 2020, 12:13 PM
Ipang