Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions exercises/random_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,16 @@
Output:
The random number is: 4
*/

#include <iostream>
#include <cstdlib>

int numGenerator(){
srand(time(NULL));
return rand() % 100 + 1;
}

int main(){
std::cout << "A random number between 1 and 100: " << numGenerator() << std::endl;
return 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 0 non è molto significativo e non vi è una determinata semantica. Per migliorare la leggibilità potresti definire:

#define EXIT_SUCCESS 0;

E utilizzarla nel seguente modo.

Suggested change
return 0;
return EXIT_SUCCESS;

}