top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Count how many integers from 1 to N contains 0's as a digit?

+2 votes
423 views

Count how many integers from 1 to N contains 0's as a digit? Please share the sample c program?

posted Feb 22, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Code in C

#include< stdio.h>
int main()
{
    int n,rim,count=0,i,temp;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        temp=i;
        while(temp)
        {
           rim=temp%10;
           if(rim==0)
           {
                count++;
                break;
           }
           temp=temp/10;
        }
    }
    printf("%d",count);
}
answer Feb 23, 2016 by Purabi Sarkar
Similar Questions
0 votes

You are given 2 long integers having n digits each and you are required to multiply them using C.

Assumptions
Numbers are represented in an array of size n .
Calculate the time complexity using traditional divide and conquer

0 votes

Given an unordered array A of size n and integer x. What is the best complexity to find two elements in A whose sum is x?
Share the algo, its complexity and if possible C code.

...