- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

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

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.

#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; }

0 9 2439

- Related Questions & Answers
- Count positive integers with 0 as a digit and maximum ‘d' digits in C++
- Count numbers having 0 as a digit in C++
- K-th digit in ‘a’ raised to power ‘b’ in C++
- Count ways to express ‘n’ as sum of odd integers in C++
- Count n digit numbers not having a particular digit in C++
- Digit Count in Range
- Count of Numbers in a Range where digit d occurs exactly K times in C++
- Find the Number which contain the digit d in C++
- Count of m digit integers that are divisible by an integer n in C++
- Find minimum possible digit sum after adding a number d in C++
- Count numbers from 1 to n that have 4 as a digit in C++
- Validate input: replace all ‘a’ with ‘@’ and ‘i’ with ‘!’JavaScript
- Count of Numbers in a Range divisible by m and having digit d in even positions in C++
- Program to count n digit integers where digits are strictly increasing in Python
- Count numbers with unit digit k in given range in C++

Advertisements