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
16 changes: 16 additions & 0 deletions random_number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//Program that generates a random number

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

int generate(){
return rand()%100+1;
}

int main(){
srand(time(NULL));
cout << "The random number generated (1-100) is: " << generate() << 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;

}