76 236
Assignments Done
Successfully Done
In May 2019

Answer to Question #14596 in C++ for dfarajzade

Question #14596
Write a program that creates a file containing TotalCount random integers (in character
format) in the range 0 to HighValue-1. Write PerLine integers per line. Separate each integer
with one space. End each line with the correct line termination for your computer.
The user is prompted for and enters HighValue, which should be an integer larger than zero.
Then the user is prompted for and enters PerLine, which is an integer greater than zero, and
TotalCount, which also is an integer greater than zero. Finally the user is prompted for and
enters the file name.
Construct a Random object and use its method nextInt(int Top), which returns an int in the
range 0..Top-1.
Expert's answer
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int nextInt(int top){
return rand()%top;
int main (){
int high,perline,total;
cout<<"Please enter High Value\n";
cout<<"Please enter PerLine\n";
cout<<"Please enter TotalCount\n";
for (int i = 0 ; i < total ; i++){
& if (i % perline == 0) cout<<endl;
& cout<<nextInt(high)<<' ';

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions