Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that uses the random number generator to create sentences. The p

ID: 3544545 • Letter: W

Question

Write a program that uses the random number generator to create sentences. The program should use four arrays of pointers to char called article, noun, verb and preposition. The sentences are constructed in the following order: article, noun, verb, preposition, article, noun. The program should generate 20 sentences. The arrays should contain:


article "the", "one", "a", "some", "any"
noun "boy", "girl", "dog", "town", "car"
verb "drove", "jumped", "walked", "ran", "skipped"
preposition "to", "from", "over", "under", "on"


Example Program Session:


A dog skipped to some dog.
One town ran from a girl.
A dog skipped to some dog.
Any car jumped over the car.
One girl jumped on a car.
Any car skipped over the dog.
Some town drove from any town.
A dog skipped to some dog.
A girl skipped from some dog.
A car skipped over the dog.
The boy walked under one boy.
Some town ran from any girl.
The dog walked to a boy.
The boy walked under one boy.
The boy walked under one boy.
One girl ran on a girl.
A dog skipped to some dog.
Any car jumped over the car.
A car skipped over some dog.
A dog skipped to some dog.

Press any key to continue . . .

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main()
{
srand((unsigned)time(NULL));
char *article[5] = {"the", "one", "a", "some", "any"};
char *noun[5] = {"boy", "girl", "dog", "town", "car"};
char *verb[5] = {"drove", "jumped", "walked", "ran", "skipped"};
char *preposition[5] = {"to", "from", "over", "under", "on"};
int counter;

for(counter = 0; counter < 20; counter++)
printf("%s %s %s %s %s %s. ", article[rand()% 5], noun[rand()% 5], verb[rand()% 5], preposition[rand()% 5], article[rand()% 5], noun[rand()% 5]);

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote