
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Count all possible N digit numbers that satisfy the given condition in C++
In this tutorial, we will be discussing a program to find the number of possible N digit numbers that satisfy the given condition.
For this we will be provided with an integer. Our task is to check which one of number having N digits follow
Number + Reverse(Number) = 10N -1
Example
#include <bits/stdc++.h> using namespace std; //returning the count of numbers string count_num(int N){ if (N % 2 == 1) return 0; string result = "9"; for (int i = 1; i <= N / 2 - 1; i++) result += "0"; return result; } int main(){ int N = 4; cout << count_num(N); return 0; }
Output
90
- Related Articles
- Count subsets that satisfy the given condition in C++
- Find numbers a and b that satisfy the given condition in C++
- Count index pairs which satisfy the given condition in C++
- Count of all N digit numbers such that num + Rev(num) = 10^N - 1 in C++
- Count n digit numbers divisible by given number in C++
- Count triplet pairs (A, B, C) of points in 2-D space that satisfy the given condition in C++
- How to count the number of values that satisfy a condition in an R vector?
- Count Possible Decodings of a given Digit Sequence in C++
- Find n positive integers that satisfy the given equations in C++
- Count n digit numbers not having a particular digit in C++
- Finding all the n digit numbers that have sum of even and odd positioned digits divisible by given numbers - JavaScript
- Find permutation of first N natural numbers that satisfies the given condition in C++
- Program to find number of subsequences that satisfy the given sum condition using Python
- Count numbers (smaller than or equal to N) with given digit sum in C++
- Count numbers from 1 to n that have 4 as a digit in C++

Advertisements