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
What will strcmp("Astring", "Astring"); return a) A positive value b) A negative value c) Zero
What is class in c++ with example?
What is pure virtual function? Or what is abstract class?
What is lambda expression c++?
How does atoi function work?
What is format for defining a structure?
What are smart pointers?
How do you establish an is-a relationship?
What is the basic structure of a c++ program?
What do you mean by const correctness?
Is it possible to provide special behavior for one instance of a template but not for other instances?
Is c++ the hardest programming language?
What is static function? Explain with an example
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
What is a dangling pointer in c++?