Purpose of the program : Store numbers in an array. Show the stored numbers and
ID: 3545832 • Letter: P
Question
Purpose of the program : Store numbers in an array. Show the stored numbers and create a histogram of the stored numbers. Step 1 Receive 8 numbers into an array using a loop . Step 2 Show the stored numbers using a loop. Step 3 Show a histogram of the entered 8 numbers. (Hint: use nested loops.)Output should look like this:
Please Enter #1 : 2
Please Enter #2 : 0
Please Enter #3 : 1
Please Enter #4 : 4
Please Enter #5 : 2
Please Enter #6 : 3
Please Enter #7 : 9
Please Enter #8 : 2
You Entered : 20142392
2 : **
0 :
1 : *
4 : ****
2 : **
3 : ***
9 : *********
2 : **
Press any key to continue . . .
Purpose of the program : Store numbers in an array. Show the stored numbers and create a histogram of the stored numbers. Step 1 Receive 8 numbers into an array using a loop . Step 2 Show the stored numbers using a loop. Step 3 Show a histogram of the entered 8 numbers. (Hint: use nested loops.)
Output should look like this:
Please Enter #1 : 2
Please Enter #2 : 0
Please Enter #3 : 1
Please Enter #4 : 4
Please Enter #5 : 2
Please Enter #6 : 3
Please Enter #7 : 9
Please Enter #8 : 2
You Entered : 20142392
2 : **
0 :
1 : *
4 : ****
2 : **
3 : ***
9 : *********
2 : **
Press any key to continue . . .
Explanation / Answer
THIS IS WRITTEN IN C . So compile accordingly
//Program Starts
#include<stdio.h>
int main()
{
int arr[8],i,j;
for(i=0;i<8;i++)
{
printf("Please Enter #%d : ",i+1);
scanf("%d",&arr[i]);
}
printf(" You Entered : ");
for(i=0;i<8;i++)
{
printf("%d",arr[i]);
}
printf(" ");
for(i=0;i<8;i++)
{
printf("%d : ",arr[i]);
for(j=0;j<arr[i];j++)
{
printf("*");
}
printf(" ");
}
return 0;
}
//End Of Program
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.