#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
    int N,A[8];

cout<<"Enter the number:";
cin>>N;

srand(time(0));


for(int i=1;i<=8;i++)
{
    A[i]=rand()%40+10;

for(int j=0;j<1;j++)
{
cout<<A[i];
}

cout<<" ";
}


    return 0;
}

the quetion as the following
write a program that prompts the user to enter a number N then generates N DISTINCT random integers between 10 and 40 inclusive and stores them in array A the program will prints the elements of the array
i wish to help me solve this question

To generate integers between 10 and 40 inclusive you can use:

rand()%31 + 10;

By N DISTINCT random integers, I assume that it means N different integers. So you'd have an array[N] and keep
generating random range numbers, check if they're already present in the array and if not place the number in the array until you reach array[N - 1]
You would also want to validate that the number N entered is not more than the number of integers between 10 and 40 inclusive.

commented: Good thinking of mathematical consequences of uniqueness: ' not more than the number of integers between 10 and 40 inclusive' +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.