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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe about storage allocation and scope of global, extern, static, local and register variables?

690


What are maps in c++?

480


What is problem with overriding functions?

582


When to use “const” reference arguments in a function?

563


Explain the concept of friend function in c++?

580






What are c++ data types?

616


Explain the concept of dynamic allocation of memory?

600


Why do we use classes in programming?

546


What is pointer to array in c++?

587


What is the full name of logo?

566


What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h

589


How can we access protected and private members of a class?

566


What is the hardest coding language to learn?

580


How do I start a c++ project?

564


Implement stack operations with pointers with appropriate exception checks.

540