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

How the delete operator differs from the delete[]operator?

0 Answers  


given the code segment below void main() { cout<<"my no. is"; } question is how can we get the output hai aravind my no. is 99999999999 without editig the main().

2 Answers  


When does a name clash occur?

1 Answers  


Why can templates only be implemented in the header file?

0 Answers  


How would you implement a substr() function that extracts a sub string from a given string?

0 Answers  






What is scope operator in c++?

0 Answers  


What are c++ templates used for?

0 Answers  


What is &x in c++?

0 Answers  


What is the use of main function in c++?

0 Answers  


What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor

0 Answers  


How do you print a string on the printer?

0 Answers  


What do you mean by inheritance in c++? Explain its types.

0 Answers  


Categories