Largest and Smallest N | C ++ program to find the largest and smallest N - digit numbers in Octal Number System ; Function to return the largest N - digit number in Octal Number System ; Append '7' N times ; Function to return the smallest N - digit number in Octal Number System ; Append '0' ( N - 1 ) times to 1 ; Function to print the largest and smallest N - digit Octal number ; Driver code ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; string findLargest ( int N ) { string largest = string ( N , '7' ) ; return largest ; } string findSmallest ( int N ) { string smallest = "1" + string ( ( N - 1 ) , '0' ) ; return smallest ; } void printLargestSmallest ( int N ) { cout << " Largest : ▁ " << findLargest ( N ) << endl ; cout << " Smallest : ▁ " << findSmallest ( N ) << endl ; } int main ( ) { int N = 4 ; printLargestSmallest ( N ) ; return 0 ; }