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