Generate random number

    0

    0

    Giovanny Gongora

    Codiga's C++ Recipes

    Random number generator

    #include<iostream>
    #include<time.h>
    #include<stdlib.h>
    
    #define MAX_NUM 10
    using namespace std;
    void randNum(){
      int random;
      srand(time(NULL));
      for(int i = 0; i < 10; i++){
        random = rand()%MAX_NUM;
        cout << random << endl;
      }
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.