- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Count ‘d’ digit positive integers with 0 as a digit in C++

In this tutorial, we will be discussing a program to find the numbers having ‘d’ digits with 0 as a digit.

For this we will be provided with a number ‘d’. Our task is to count and print the number of positive integers having ‘d’ digits and 0 as one of their digit.

## Example

#include<bits/stdc++.h> using namespace std; //counting the number of 'd' digit numbers int count_num(int d) { return 9*(pow(10,d-1) - pow(9,d-1)); } int main(){ int d = 1; cout << count_num(d) << endl; d = 2; cout << count_num(d) << endl; d = 4; cout << count_num(d) << endl; return 0; }

## Output

0 9 2439

- Related Articles
- Count positive integers with 0 as a digit and maximum ‘d' digits in C++
- Count numbers having 0 as a digit in C++
- Count n digit numbers not having a particular digit in C++
- Count of m digit integers that are divisible by an integer n in C++
- Digit Count in Range
- Count numbers from 1 to n that have 4 as a digit in C++
- Count numbers with unit digit k in given range in C++
- Program to count n digit integers where digits are strictly increasing in Python
- Count of Numbers in a Range where digit d occurs exactly K times in C++
- Count Possible Decodings of a given Digit Sequence in C++
- Count of Numbers in Range where first digit is equal to last digit of the number in C++
- Count n digit numbers divisible by given number in C++
- Count of Binary Digit numbers smaller than N in C++
- Count of Numbers in a Range divisible by m and having digit d in even positions in C++
- Python – Split Numeric String into K digit integers

Advertisements