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; }
3 Respuestas
+ 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 ...
+ 1
Yes I wanted to do that to count the frequency of zeroes thanks that would help me 👍👌
+ 1
Alright buddy, happy coding! 👍