C++ Program to Generate Random Numbers between 0 and 100
Problem
Write a C++ Program to Generate Random Numbers between 0 and 100.
Solution
Below is a sample code snippet demonstrating how you can generate random numbers between 0 and 100 in C++.
#include<iostream> #include<stdlib.h> using namespace std; int main() { int i; int num; cout<<"Random Numbers\n"; for(i=1;i<=10;i++) { num=rand()%100; cout<<" "<<num<<" "; } cout<<"\n"; return 0; }
Output

Leave Your Comment