Skip to main content

Posts

Showing posts from November, 2020

Silly sentence

Do you want to display silly sentences? And using code? Have three arrays with subjects, objects and verbs and randomize them.  I have used latin words in the program, you can replace them with any language of your choice and amuse your friends. #include<iostream> using namespace std; class sentence { string subject; string object; string verb; public: sentence(); sentence(string,string,string); void print_sentence(); }; sentence::sentence() { subject = ""; object = ""; verb = ""; } sentence::sentence(string sub,string obj,string verb) { this->subject = sub; this->object = obj; this->verb = verb; } void sentence::print_sentence() { cout<<subject<<" "<<object<<" "<<verb<<endl; } int main() { string sub_arr[]= {"agricola","regina","filia",&q