In this code I'm generate random number in specific range, but I want the out put of array must be
host101
host102
host102
host103
host102
I mean adding the word "host" to every number that is generate randomly, how can do this please? this is code
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char *argv[])
{
int a[50];
srand(time(NULL));
int n = rand() % (8 + 1 - 4) + 4 ;
for(int i=0;i<n;i++){
a[i] = rand() % (104 + 1 - 101) + 101 ;
printf( "No. of random selected node = %d\n", a[i]);
}
}
I'm sorry about my bad english
Aucun commentaire:
Enregistrer un commentaire