Input reads in the array positions and range for random generation.

How to write a C Program to Input reads in the array positions and range for random generation in C Programming Language ?

Solution:

  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <math.h>
  4.  
  5.     /*Input reads in the array positions and range for random generation.*/
  6.  
  7. void readInput()    {
  8.     int inputArray[2];
  9.  
  10.     puts("Please enter the number of positions and the range second:");
  11.     scanf("%d %d", &inputArray[0], &inputArray[1]);
  12.  
  13.     return inputArray[0 - 1];
  14. }
  15.  
  16. int main()  {
  17.     int inputArray[2] = readInput();
  18.  
  19.     printf("%d %d", inputArray[0], inputArray[1]);
  20. }


Learn More :