Write a C++ Program to Generate Random Numbers between 0 and 100



Write a C++ Program to Generate Random Numbers between 0 and 100..

Answer / hr

Solution:
/* C++ Program to Generate Random Numbers between 0 and 100 */
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
int i; //loop counter
int num; //store random number
cout<<"Generating Random Numbers Below ::

";
for(i=1;i<=10;i++)
{
num=rand()%100; //get random number
cout<<" "<<num<<" ";
}
cout<<"
";
return 0;
}
Output:
/* C++ Program to Generate Random Number between 0 and 100 */
Generating Random Numbers Below ::
41 67 34 0 69 24 78 58 62 64
Process returned 0

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is the difference between reference and pointer?

0 Answers  


What is the use of object in c++?

0 Answers  


Write about an iterator class?

0 Answers  


What is the default width for ouputting a long integer using the insertion operator?

0 Answers  


What is atoi?

0 Answers  






What is the use of "new" operator?

0 Answers  


Can a constructor return a value?

0 Answers  


Which operator cannot overload?

0 Answers  


How would you stop a class from class from being derived or inherited?The constructer should not be Private,as object instantiation should be allowed.

15 Answers   Satyam,


Is c++ the most powerful language?

0 Answers  


How do you define/declare constants in c++?

0 Answers  


Difference between a copy constructor and an assignment operator.

0 Answers  


Categories