# C program to generate random number devquora

Posted On: Dec 23, 2020 ### Overview:

In this article, I want to explain What is number, random number? Moreover, I will demonstrate how to generate random number. Then, explain Logic to generate random numbers and write a C program to generate random numbers. After all, I will explain the C program to generate random numbers with output.

After all, I will write the logic of a C to check if the number is palindrome and explain it with output.

### What is a Number?

Number is an object that uses digits to perform mathematical tasks. Calculus, which is a branch of mathematics, includes many numbers such as integers, whole numbers, real numbers, and imaginary numbers. Here, I will discuss numbers to perform arithmetic addition operations. Moreover, Number is a combination of digits, some symbols and decimal points. For instance, 127.23 is a rational number.

### What is random number?

Random numbers are numbers that occur in a sequence such that two conditions are met: (1) the values are uniformly distributed over a defined interval or set, and (2) it is impossible to predict future values based on past or present ones. Random numbers are important in statistical analysis and probability theory.

### Demonstration to generate random number ### Logic to generate random number

• Step 1: We use a modulus operator in our program. If you evaluate a % b where a and b are integers then result will always be less than b for any set of values of a and b.
• Step 3: For example, For a = 1243 and b = 100 then, a % b = 1243 % 100 = 43
• Step 5: For a = 99 and b = 100 then, a % b = 99 % 100 = 99
• Step 7: For a = 1000 and b = 100 then,  a % b = 1000 % 100 = 0

### C program to generate random number

```#include
#include
int main()
{
int c, n;
printf("Ten random numbers in range [1-100] are as follows: ");
for (c = 1; c <= 10; c++)
{
n = rand() % 100 + 1;
printf("%d, ", n);
}
return 0;
}
```

The output of the Program with code: Conclusion:

Random numbers are numbers that occur in a sequence such that two conditions are met: (1) the values are uniformly distributed over a defined interval or set, and (2) it is impossible to predict future values based on past or present ones. Random numbers are important in statistical analysis and probability theory. After the successful compilation of the program, this program displays the following output: Ten random numbers in range [1-100] are as follows: 42, 68, 35, 1, 70, 25, 79, 59, 63, 65

Never Miss an Articles from us.

## Related Articles

#### C Program to convert Decimal to Binary Number

A Decimal Number is constructed with any digit from 0 to 9. For instance, 24 is a Decimal Number constructed from the digits 2 and 4. A Binary Number is constructed with digits 0 and 1. For instance, ..

#### C program to reverse a string

This program reversed the entered string that means opposite of the previous string sequence...

#### C program to reverse an Integer number

Are you want a demonstration of The C Program that reverses an Integer number? This Program reversing the sequence of digits in an Integer. After the successful compilation of the program, a message..