Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

what do that programm???

+2 votes
asked Apr 28, 2020 by gfrve dfss (370 points)
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
 int main(){
     const int x=7;
     const int y=14;
     int n[10] = {};
     for(int i = 0; i < 10; i++){
     n[i]= x + rand()%(y - x + 1);
     
         for(int i = 0; i < 10; i++);
 {
 if(n[i] >= 10)
 {
 n[i] -= 10;
 }
 cout << n[i] << " | ";
 }

     }
}

in c++

2 Answers

0 votes
answered Apr 30, 2020 by mark (360 points)

it appears that it is supposed to generate ten random numbers with the | character in-between. it looks like the person who wrote this forgot to put in the time as a seed here is a revised program(changes in bold). I thought this because to generate a different number each time you need a changing seed a because they have ctime and time is a common seed It lead me to think that is was a random number program

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
 int main(){
     time_t time_;
     const int x=7;
     const int y=14;
     int n[10] = {};
     time(&time_);
     srand(time_);
     for(int i = 0; i < 10; i++){
     n[i]= x + rand()%(y - x + 1);
    
         for(int i = 0; i < 10; i++);
 {
 if(n[i] >= 10)
 {
 n[i] -= 10;
 }
 cout << n[i] << " | ";
 }

     }
}

0 votes
answered Apr 30, 2020 by Likith Liki (140 points)
return 0;

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...