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 are templates? where we should use it?
Write a corrected statement in c++ so that the statement will work properly. if (x = y) x = 2*z;
What is the maximum combined length of command line arguments including the space between adjacent arguments?
Is c++ harder than java?
Who calls main function?
Should I learn c or c++ first?
Is c++ a difficult language?
what does the following statement mean? int (*a)[4]
How to declare a function pointer?
Why do we use classes in c++?
What is Name Decoration?
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.