You are given an integer N.
Each digit in the number contains a certain number of holes.

πŸ”’ Hole Definition:

  • Digits 0, 4, 6, 9 β†’ have 1 hole
  • Digit 8 β†’ has 2 holes
  • All other digits β†’ have 0 holes

🎯 Task

Calculate and print the total number of holes present in all digits of the given number.


πŸ“₯ Input Format

  • A single integer N

πŸ“€ Output Format


πŸ“Œ Constraints

  • 1≀N≀1091 \leq N \leq 10^91≀N≀109

πŸ§ͺ Example 1

Input:

649578

Output:

5

Explanation:

  • 6 β†’ 1 hole
  • 4 β†’ 1 hole
  • 9 β†’ 1 hole
  • 5 β†’ 0 holes
  • 7 β†’ 0 holes
  • 8 β†’ 2 holes

Total = 1 + 1 + 1 + 0 + 0 + 2 = 5


πŸ§ͺ Example 2

Input:

630

Output:

2

Explanation:

  • 6 β†’ 1 hole
  • 3 β†’ 0 holes
  • 0 β†’ 1 hole

Total = 2

C Program

#include <stdio.h>

int countHoles(int number) {
    int holes = 0;

    while (number > 0) {
        int digit = number % 10;

        if (digit == 0 || digit == 4 || digit == 6 || digit == 9) {
            holes += 1;
        } else if (digit == 8) {
            holes += 2;
        }

        number /= 10;
    }

    return holes;
}

int main() {
    int number;
    scanf("%d", &number);   // ❗ No print message

    printf("%d", countHoles(number));  // ❗ Only output

    return 0;
}

1 Comment

  • Problem Statement: Featured Product - Dheeraj Hitech · April 3, 2026 at 11:51 am

    […] product that sells the most on a given day becomes the featured product for the next […]

    Leave a Reply

    Avatar placeholder

    Your email address will not be published. Required fields are marked *