Random integer

    0

    1

    Giovanny Gongora

    Codiga's C++ Recipes

    Generate a random integer

    #include <iostream>
    using namespace std;
    
    int rndInt(){
      srand(1); //set random seed for reproducible result
      // this will generate numbers from 3 to 3+5=8
      for(int i = 0; i < 10; i++){
        cout << rand()%5+3 << " ";
      }
      return 0;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.