Q1. (Bar Chart /Histogram printing) Write a C program that reads in five numbers
ID: 3551583 • Letter: Q
Question
Q1. (Bar Chart /Histogram printing) Write a C program that reads in five numbers (each between 1 and 30). For each number read, your program should print a line containing that number of adjacent asterisks. For example, if your program reads the number seven, it should print *******.
Q2. Write a C code that draws a shape as follows:
7
+
Shape:
+
+++
+++++
+++++++
+++++
+++
+
Press any key to continue . . .
Q3. Write a C program that prompts the users to enter the number of students then calculates and displays the average number of hours that a student spent on doing programming each day over a three day weekend period.
Explanation / Answer
Remember me, I did rest of your 3 HW questions and asked you to post rest of them separately.
Q1.
#include <stdio.h>
int main(){
int A[5];
int i,j;
printf("Enter the 5 numbers : ");
for(i=0;i<5;i++){
scanf("%d",&A[i]);
}
for(i=0;i<5;i++){
for(j=0;j<A[i];j++){
printf("*");
}
printf(" ");
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.