#include using namespace std; #include #include const int max_items=1000; const int max_word_length=64; unsigned int seed=0; int return_integer(); // Report no. of items void report_nb_items(int nb,...

Hello i need your help with this exercice it's urgent, i'm learning c++ but i cant do it i can't do this homework and it's urgent, i would be greatful for your help, the instructions are in the files



#include using namespace std; #include #include const int max_items=1000; const int max_word_length=64; unsigned int seed=0; int return_integer(); // Report no. of items void report_nb_items(int nb, char *item_name); // Puts parameter word into the plural iff // parameter nb is more than 1. // Assumes parameter word contains only a word // Assumes plural is always made by adding s void pluralize(int nb, char *word); int main() { report_nb_items(return_integer(), (char *)"user"); report_nb_items(return_integer(), (char *)"transaction"); report_nb_items(1, (char *)"brain"); report_nb_items(2, (char *)"biological parent"); report_nb_items(return_integer(), (char *)"goal"); return 0; } int return_integer() { srand((unsigned int)time(NULL)); seed=seed+rand(); return (int) (((float)seed/(float)(RAND_MAX)) * max_items); } void report_nb_items(int nb, char *item_name){ char word[max_word_length]; if (strlen(item_name) > max_word_length-2) { cout < "internal="" error\n";="" exit(1);="" }="" strcpy(word,="" item_name);="" pluralize(nb,="" word);="" cout="">< "you="" have=""><><"><><"\n"; }="" void="" pluralize(int="" nb,="" char="" *word){="" if="" (nb="">1) { } } // winning_numbers.cpp #include using namespace std; #include #include const float max_winner=1000.0; // Checks if paramenter r is a winner // A real is a winner if it is between 0 and 1000 (inclusive) and either its integer part is even (example: 2.718 is a winner) or both its half and square are winners (example: 1.618 is a winner because 0.809 and 2.617924 are winners). int is_winner(const float r); int main() { srand((unsigned int)time(NULL)); float r = 2.7189; for (int i=0;i<20;i++) {="" r="((float)rand()/(float)(RAND_MAX))" *="" max_winner;="" cout="">< r="">< "\t"="">< is_winner(r)="">< "\n";="" }="" return="" 0;="" }="" int="" is_winner(const="" float="" r){="" if="" (r=""><= max_winner="" &&="" r="">= 0) { if ( r%2=0 ) { return true; } else if (r/2= is_winner(r) || r*r = is_winner(r) ){ return true; } } }
Jan 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here