How to Generate 6 Digit Random Number C?

Hello Friends Today, through this tutorial, I will tell you how to generate a 6 digit Unique random number in C?.

In C, you can use the `rand` function to generate random numbers. Here’s an example of generating a 6 digit unique random number:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int generateRandom6DigitNumber() {
return rand() % 900000 + 100000;

int main() {
// Seed the random number generator with the current time

// Generate a random 6-digit number
int random6DigitNumber = generateRandom6DigitNumber();
printf("Random 6-digit number: %d\n", random6DigitNumber);

return 0;

In this example, `rand() % 900000 + 100000` generates a random number between 0 and 899999, and then we add 100000 to ensure that the number is always a 6-digit number.