Write a C++ Program to Generate Random Numbers between 0 and 100
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 |
How the delete operator differs from the delete[]operator?
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().
When does a name clash occur?
Why can templates only be implemented in the header file?
How would you implement a substr() function that extracts a sub string from a given string?
What is scope operator in c++?
What are c++ templates used for?
What is &x in c++?
What is the use of main function in c++?
What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor
How do you print a string on the printer?
What do you mean by inheritance in c++? Explain its types.