Thursday, 1 August 2013

Randomize();

Write a program to print the name randomly from the given names

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
const int maxlength=50;
int main()
{
    char word[maxlength];
    char words[][maxlength] =
    {
        "Mahi",
        "Priyanka",
        "Pallavi",
        "Bhavna",
        "Tani"
    };
    randomize();
    clrscr();
    int n=random(5);
    strcpy(word,words[n]);

    cout<<"\n\t"<<word;
    getch();
}

Here is the output :)

  

No comments:

Post a Comment