Monday, 16 June 2014

C++ program to guess a random number



Here is a C++ program to guess a random number


 SOURCE CODE OUTPUT
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
    int num,num1;
    num=rand()%15+1;
    cout<<"Guess a number between 1 to 15 ";
    cin>>num1;
    if(num==num1)
       cout<<"Excellent! You guess correctly";
    else
        cout<<"Wrong guess number was "<<num;
    return 0;
}


Any questions regarding to program please write in comments.

No comments:

Post a Comment