Answer to Question #191178 in C++ for python

Question #191178

1. How to generate random number in C++, write a simple C++ program that will generate random number from 1 to 100?


1
Expert's answer
2021-05-17T09:56:20-0400
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int n;
    cout << "How many random number do yoi want? ";
    cin >> n;
    for (int i=0; i<n; i++) {
        int q = rand() % 100 + 1;
        cout << q << endl;
    }
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment