How to write a C Program that Generates 10 Random Integers Number Between 0 and 99 in C Programming Language ?
This C program generates 10 random integers between 0 and 99.
The srand() function generates a seed value for the rand() function.
Solution For C Program:
/*This C program generates 10 random integers between 0 and 99. The srand() function generates a seed value for the rand() function.
*/
#include <msp430.h>
#include <stdio.h>
#include <stdlib.h>
/*
* main.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
int Num[10]; //Initializes an array of integers of size 10
int i=0; //counter for position in array
srand(time(NULL)); //generates a seed value for rand()
//for loop that places generated numbers in the corresponding array position in the order that they are generated
for(i=0;i<10;i++){
Num[i] = rand()%100; //modulo 100 to keep the integers between 0 and 99
}
return 0;
}