Assignments » Library Function » Set1 » Solution 4

Write a program which display a number between 10 to 100 randomly.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

int main()
{
	int n;
	randomize();
	n=random(91)+10;
	cout<<"The randomly selected number is :"<<n;
	getch();
	return 0;
}

#include<iostream>
#include<cstdlib>
#include <ctime>
using namespace std;

int main()
{
	int n;
	srand(time(0));
	n = rand() % 91 + 10;
	cout<<"The randomly selected number is :"<<n;
	
	return 0;
}

SAMPLE RUN # 1

The randomly selected number is : 34

SAMPLE RUN # 2

The randomly selected number is : 45

SAMPLE RUN # 3

The randomly selected number is : 76

 

«back