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 |
What is setw manipulator in c++?
Should the this pointer can be used in the constructor?
Explain how a pointer to function can be declared in C++?
Is c++ vector dynamic?
What is purpose of new operator?
What is the difference between std::vector and std::list
Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)
How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?
What are smart pointers?
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;
What is a protocol class?
how many rounds and wt type of questios ask in the written test for first round 2. tech. round 3. and futher rounds