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;
}
Learn More :
Integer
- How to Write a C program to perform basic math operations on two input whole numbers. The basic operations are addition, subtraction, multiplication, integer division, real division, and modulus.
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C program to Given a vector (integer or real), determine what is the maximum value of element what is the position in which this element is located
- Lower-Upper Case/Positive-Negative Integer
- Give me an integer and I will sum it with the previous natural numbers
- Find the union and intersection of two sets of integer store it in two array C Program
- C Program to Detect int Underflow-Overflow using if-else
- Menu Driven Program to Read Two Integers Find Sum, Difference and Product C Program
Random
Generate
- How To Write a C program that generates two random numbers ?
- C program generates a random number and uses an algorithm to generate 9 other numbers.
- C Program To Generating Fibonacci Series Using Recursion
- C Program To Generate Multiplication Table
- C Program to Generate Specific Formats
- Write a c program to accept a string from user & generate following pattern (e.g, input "abcd")
- ACLK (32768 Hz) to generate a one second timer and toggles an LED