Answer to Question #292862 in C++ for Rubie Ann

Question #292862

Design a program that will print 7 random numbers using the while looping statement and modulo operator.

1
Expert's answer
2022-02-01T12:27:02-0500
#include <iostream>


#include <ctime>


#include <cstdlib>


using namespace std;


int main(){


    // Initializing random number generator in C++


    srand(time(0));


    cout<<"Seven Random numbers between 1 and 20:"<<endl;


    int x = 0; /* <<< Initialization */
while(x < 7)
{
    cout << 1+ (rand() %20) <<"\n";
    
       x++;
}
    
      return 0;
}

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

LATEST TUTORIALS
New on Blog