- 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
Largest Even and Odd N-digit numbers in C++
In this tutorial, we are going to write a program that finds the largest even and odd number of n digits number.
Let's see the steps to solve the problem.
- Initialise the number n.
- The largest odd number is pow(10, n) - 1.
- The largest even number is odd - 1.
Example
Let's see the code.
#include <bits/stdc++.h> using namespace std; void findEvenAndOddNumbers(int n) { int odd = pow(10, n) - 1; int even = odd - 1; cout << "Even: " << even << endl; cout << "Odd: " << odd << endl; } int main() { int n = 6; findEvenAndOddNumbers(n); return 0; }
Output
If you run the above code, then you will get the following result.
Even: 999998 Odd: 999999
Conclusion
If you have any queries in the tutorial, mention them in the comment section.
- Related Articles
- Product of N with its largest odd digit in C
- Largest even digit number not greater than N in C++
- Even numbers at even index and odd numbers at odd index in C++
- Print all n-digit numbers with absolute difference between sum of even and odd digits is 1 in C++
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers - JavaScript
- Largest N digit number divisible by given three numbers in C++
- Finding all the n digit numbers that have sum of even and odd positioned digits divisible by given numbers - JavaScript
- What are even and odd numbers?
- Count rotations of N which are Odd and Even in C++
- Find even odd index digit difference - JavaScript
- Golang Program to Print the Largest Even and Largest Odd Number in a List
- Identify in number 70169308, which digit is in odd and which digit is in even place?
- Largest number less than N with digit sum greater than the digit sum of N in C++
- Count n digit numbers not having a particular digit in C++
- Check whether product of 'n' numbers is even or odd in Python

Advertisements