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 are templates? where we should use it?

2 Answers   Alcatel,


Write a corrected statement in c++ so that the statement will work properly. if (x = y) x = 2*z;

2 Answers  


What is the maximum combined length of command line arguments including the space between adjacent arguments?

0 Answers  


Is c++ harder than java?

0 Answers  


Who calls main function?

0 Answers  






Should I learn c or c++ first?

0 Answers  


Is c++ a difficult language?

0 Answers  


what does the following statement mean? int (*a)[4]

0 Answers  


How to declare a function pointer?

0 Answers  


Why do we use classes in c++?

0 Answers  


What is Name Decoration?

2 Answers   Lucent,


Problem 5: Hero's Formula is A method for calculating the area of a triangle when you know the lengths of all three sides. Let a, b, c be the lengths of the sides of a triangle. The area is given by:A= pp-ap-b(p-c) | wherep= a+b+c2 | | Write a C-language code to calculate area of triangle using above method. Take the three lengths of the triangle from the user and display the area that your program calculates.

0 Answers   Maxobiz,


Categories