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

Project 9 - PrintRandomNumbers In this lab, you will create a program that uses

ID: 3607472 • Letter: P

Question

Project 9 - PrintRandomNumbers In this lab, you will create a program that uses each of the three loops we have discussed to print random numbers 1-10, 1-50, and 1-100 respectively to the screen console Lab objectives: Identify differences in loops when trying to accomplish the same task Use of a while loop Use of a for loop Use of a do-while loop Use of incremental operator e . * Ability to generate random numbers » . . bash . "scottston t Requirements: while loop randon number 1 is:2 Use a while loop to print random numbers 1-10 Use a do loop to print random numbers 1-50 Wwhile Loop randon nunber 2 i:8 * While loop randon nunber 3 is:1 while loop randon number 4 is:7 While loop randon nunber 5 is:1 * Use a for loop to print random numbers 1-100 hie loop random number 6 is:5 While loop randon nunber 7 is:6 While loop randon nunber 8 is:7 While loop randon nunber 9 is:7 While loop randon number 10 is:5 Do-while loop random number 1 is:13 Do-while loop random number 2 is:7 Do-while loop random number 3 is:28 Append the number AFTER the naming type of loop used and iteration (concatenation) random number is:

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>   
#include <time.h>
int main()
{
int i, counter = 10 ;
srand (time(NULL));
i=1;
while(i<=counter) {
printf("While loop random number %d is : %d ",i,(rand() % 10 + 1));
i++;
}
i=1;
do{
printf("Do-While loop random number %d is : %d ",i,(rand() % 50 + 1));
i++;
}while(i<=counter) ;
for(i=1;i<=counter;i++) {
printf("For loop random number %d is : %d ",i,(rand() % 100 + 1));   
}
return 0;
}

Output: