Home / Expert Answers / Computer Science / include-include-include-int-main-int-loopcount-0-int-totalloops-0-char-choice-srand-pa792

(Solved): #include #include #include int main() { int loopCount = 0; int totalLoops = 0; char choice; srand ...



#include #include #include int main() { int loopCount = 0; int totalLoops = 0; char choice; srand(time(NULL)); do { int largest = 0; int numbers[5]; // Generate 5 random numbers and store in array for (int i = 0; i < 5; i++) { numbers[i] = rand() % 50 + 1; if (numbers[i] > largest) { largest = numbers[i]; } } // Print the array printf("Generated numbers: "); for (int i = 0; i < 5; i++) { printf("%d ", numbers[i]); } printf("\n"); // Print the largest number printf("Largest number: %d\n", largest); // Print "Yes" 5 times for (int i = 0; i < 5; i++) { printf("Yes "); } printf("\n"); loopCount++; if (loopCount >= 10) { printf("The loop has run 10 times.\n"); } else { printf("The loop has run %d times.\n", loopCount); } printf("Do you want to run again? (y/n): "); scanf(" %c", &choice); totalLoops++; } while (choice == 'y' || choice == 'Y'); printf("Program has looped %d times.\n", totalLoops); return 0; }



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe