6

C Program to Generate Random Alphabets

 2 years ago
source link: https://www.geeksforgeeks.org/videos/c-program-to-generate-random-alphabets/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

C Program to Generate Random Alphabets

C Program to Generate Random Alphabets
Hey guys. Welcome to Geeks for geeks
  • 17/08/2022

In this video, we will write a C program to generate random alphabets

To achieve this we will use rand() function to print random characters. It returns random integer values. This number is generated by an algorithm that returns a sequence of apparently non-related numbers each time it is called.

A rand() function is an inbuilt function in C STL, which is defined in header file. It is used to generate a series of random numbers. The random number is generated by using an algorithm that gives a series of non-related numbers whenever this function is called.

A srand() function is an inbuilt function in C STL, which is defined in header file. It is used to initialize random number generators. The srand() function sets the starting point for producing a series of pseudo-random integers. If srand() is not called, the rand() seed is set as if srand(1) were called at the program start. Any other value for seed sets the generator to a different starting point.

Algorithm:

Step 1: First we initialize two character arrays, one containing all the alphabets and the other of the given size n to store the result.
Step 2: Then we initialize the seed to the current system time so that every time a new random seed is generated.
Step 3: Next, we use for loop till n and store randomly generated alphabets.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK