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

What is std :: endl?

783


What is the cout in c++?

772


What is the difference between while and do while loop? Explain with examples.

828


What is fflush c++?

765


What type of question are asked in GE code writing test based on c++ data structures and pointers?

3700


Is c++ a good beginners programming language?

777


Which is best ide for c++?

745


What is searching?

862


What is data abstraction? How is it different from data encapsulation?

735


Can you explicitly call a destructor on a local variable?

786


What is exception handling? Does c++ support exception handling?

784


What is size_type?

713


Can constructor be static in c++?

845


Which operator cannot overload?

796


What is the need of a destructor?

858