Thursday, November 28, 2013

C++: Find out any 5 possible output from the program below.

// C++ Source code
#include<stdlib.h>
#include<iostream.h>
#include<conio.h>

void main()
{
randomize();
   char city[][10]={"Kathmandu", "Lalitpur", "Bhaktapur", "Pokhara", "Lumbini"};
   int fly;

   int count=1;
   while(count<=5)
   {
    for(int i=0; i<3; i++)
    {
    fly=random(2) + 1;
       cout<<city[fly]<<" : ";
    }
      cout<<endl;
      count++;
   }
   getch();
}

OUTPUT

Bhaktapur : Lalitpur : Lalitpur :
Lalitpur : Lalitpur : Lalitpur :
Bhaktapur : Bhaktapur : Bhaktapur :
Bhaktapur : Bhaktapur : Bhaktapur :
Bhaktapur : Lalitpur : Bhaktapur :

No comments:

Post a Comment