Generate N Random Hexadecimal Numbers | C ++ program for the above approach ; Maximum length of the random integer ; Function to generate N Hexadecimal integers ; Stores all the possible charcters in the Hexadecimal notation ; Loop to print N integers ; Randomly select length of the int in the range [ 1 , maxSize ] ; Print len charcters ; Print a randomly selected character ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; const int maxSize = 10 ; void randomHexInt ( int N ) { srand ( time ( 0 ) ) ; char hexChar [ ] = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' } ; for ( int i = 0 ; i < N ; i ++ ) { int len = rand ( ) % maxSize + 1 ; for ( int j = 0 ; j < len ; j ++ ) { cout << hexChar [ rand ( ) % 16 ] ; } cout << ' ' ; } } int main ( ) { int N = 3 ; randomHexInt ( N ) ; return 0 ; }