227k views
2 votes
One interesting application of computers is to display graphs and bar charts. Write an application that reads five numbersbetween 1 and 30. For each number that’s read, your program should display the same number of adjacent asterisks. For example, if your program reads the number 7, it should display *******. Display the bars of asterisks after you read all five numbers. Show a few running results in the word document.

1 Answer

6 votes

Answer:

this solution was written in c programming language

Step-by-step explanation:

#include <stdio.h>

int main(void)

{

int i, j, number;

/* ask user for numbers */

printf("Enter 5 numbers between 1 and 30: ");

/* repeat 5 times */

for (i = 0; i < 5; i++)

{

/* read in number */

scanf("%d", &number);

/* print that number of stars */

for (j = 0; j < number; j++)

{

printf("*");

}

/* bring cursor to next line */

printf("\\");

}

return 0;

}

User Remco Haszing
by
4.3k points