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 diff b/n c and c++ a. dynamic scoping b. nested switching c. declaration of variables in any code block d. separation of compilation and linking

2 Answers   Hughes,


Why iomanip is used in c++?

0 Answers  


What is a tuple c++?

0 Answers  


What are proxy objects in c++?

0 Answers  


Do we have to use initialization list in spite of the assignment in constructors?

0 Answers  


Can we make any program in c++ without using any header file and what is the shortest program in c++.

0 Answers   MCN Solutions,


What is the error in the code below and how should it be corrected?

0 Answers  


What are the two shift operators and what are their functions?

0 Answers  


Write a struct time where integer m, h, s are its members?

0 Answers  


What is the output of: String a1 = "Hello"; String a2 = "world!"; String* s1 = &a2; String& s2 = a1; s1 = &a1; s2 = a2; std::cout << *s1 << " " << s2 << std::endl;

4 Answers   Lehman Brothers,


What is the difference between a type-specific template friend class and a general template friend class?

0 Answers  


What is std namespace in c++?

0 Answers  


Categories