Hello, i made this code, it is giving me random numbers, but 1 too many, and a couple numbers out of the range..please help!!!

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main (){
    int x; //range number 1
    int y; //range number 2
    int m; //how many numbers wanted to generate
   
    cout << "Enter A Range" << endl;
    cin >> x >> y;
    cout << "Enter How Many Numbers You Want Generated Within That Range" << endl;
    cin >> m;
    cout << "The Random Numbers Are:";
   
    srand(time(NULL));
   
    for(int i; i <= m; i++){
            cout << endl;
            cout << rand () % (x - y + 1) + y << endl;
    }
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.