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
Describe about storage allocation and scope of global, extern, static, local and register variables?
What are maps in c++?
What is problem with overriding functions?
When to use “const” reference arguments in a function?
Explain the concept of friend function in c++?
What are c++ data types?
Explain the concept of dynamic allocation of memory?
Why do we use classes in programming?
What is pointer to array in c++?
What is the full name of logo?
What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h
How can we access protected and private members of a class?
What is the hardest coding language to learn?
How do I start a c++ project?
Implement stack operations with pointers with appropriate exception checks.