1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Luda [366]
4 years ago
7

(C Language) Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representa

tion of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...".
The program will ask the user to enter a non-zero positive number. Using a while loop, validate that the number is not greater than 40, and if so, re-ask for the number. Put the entire program into a sentinel-controlled loop so that the user can enter either zero (0) or a negative number to end the program.

Create constants for 1 (the minimum number for the histogram), and 40 (the maximum number for the histogram), and use these constants in the prompts, the validation condition and error message, and the sentinel-controlled loop and the histogram loop.

Hints:

Validation messages are indented 3 spaces
You can use either a pre-test loop (with the initial prompt outside the loop, and the re-prompt at the end of the loop) or a post-test loop (with the prompt inside the loop, and a decision to print the histogram also inside to loop).
Coded the histogram using a for loop (although any type of loop could be used)
Example Run:

(bold type is what is entered by the user)

Enter a non-zero positive number less than 40: 5
***** 5

Enter another non-zero positive number less than 40: 48
The number entered was greater than 40.
Please re-enter: 8
******** 8

Enter another non-zero positive number less than 40: -1

Bye...

The example run shows EXACTLY how your program input and output will look.
Computers and Technology
1 answer:
Kobotan [32]4 years ago
3 0

Answer:

Explanation:

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You

=================================

#include <stdio.h>

#include <stdlib.h>

#include <ctype.h>

#include <string.h>

int main() {

  //Declaring constants

const int MIN=1;

  const int MAX=40;

 

  //Declaring variables

  int num,i;

      printf("Enter a non-zero positive number less than 40: ");  

     

     

/* This while loop continues to execute

* until the user enters a number <=0

*/

  while(1)

  {

      scanf("%d",&num);

      if(num<=0)

      {

          break;

      }

      else if(num>40)

      {

      printf("The number entered was greater than %d.\n",MAX);

          printf("Please re-enter: ");

      }

      else

      {

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

          {

              printf("*");

          }

          printf("%d\n",num);

          printf("Enter another non-zero positive number less than 40: ");

      }

         

  }

 

  printf("bye...");

  return 0;

 

}

================================

output:

Enter a non-zero positive number less than 40:5

*****5

Enter another non zero positive number less than 40: 48

The number entered was greater than 40.

please Re-enter: 8

********8

Enter another non zero positive number less than 40: 1

bye...

---------------------------------------------

Process exited after 15.48 seconds with return value 0

Press any key to continue.......

You might be interested in
Computer design replaced ______________
bazaltina [42]
<span>Computer design replaced (B) models draw or created by hand. Technology nowadays has a big contribution in terms of planning and designing a building or a structure without burning your eyebrow facing that paper and handling your pen. Computer designs are used to make the design more accurate and more precise compared to traditional hand drawn designs.</span>
8 0
3 years ago
In the welding operations of a bicycle manufacturer, a bike frame has a long flow time. The set up for the bike frame is a 7 hou
mestny [16]

Answer:

Bike Frame Flow Time

The value-added percentage of the flow time for this bike frame is:

= 46.

Explanation:

a) Data and Calculations:

Bike Frame Flow Time:

Setup time = 7 hours

Processing time = 6 hours

Storage time = 7 hours

Flow time of the bike frame = 13 hours (7 + 6)

Value-added percentage of the flow time for this bike frame = 6/13 * 100

= 46%

b) Flow time represents the amount of time a bicycle frame spends in the manufacturing process from setup to end.  It is called the total processing time. Unless there is one path through the process, the flow time equals the length of the longest process path.  The storage time is not included in the flow time since it is not a manufacturing process.

8 0
3 years ago
Which of the following is an example of intellectual property?
Gnesinka [82]

Answer:

B. Programming code for a video game

Explanation:

An item is considered an intellectual property if it is intangible in the sense that the actual property cannot be touched and it does not have a physical presence.

Options A, C and D do not fall in this category because they are tangible and they have physical presence.

Only option A, programming source code does not fall into this category.

Hence, <em>B. Programming code for a video game </em> answers the question

8 0
3 years ago
A server needs to connect directly to the Internet. The ipconfig/all command shows that the server has been auto-assigned the IP
Deffense [45]

Answer:

Link-local address

Explanation:

IP addresses that have "FE80" as the hexadecimal representation of their first 10 bits are IPV6 reserved addresses for link-local unicast addressing. These addresses are automatically configured (though may be manually configured too) on any interface and should not be routed. They are used for addressing on a single link with the main aim, among others, of automatic configuration and routing protocol advertisement. Devices attached to this link can be accessed or reached using the link-local addresses as they don't need a global address to communicate.

However, routers will not forward datagram or packets using link-local addresses. In other words, routers are not allowed to connect to the internet using the unicast link-local addresses.

8 0
3 years ago
What is data mining ​
Vesna [10]

Answer:

Data mining is a process of extracting and discovering patterns in large data sets involving methods at the intersection of machine learning, statistics, and database systems.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Windows explorer has a pane located on the left side which can display the directory structure of one or more drives. what is th
    15·1 answer
  • What country is now the number one source of attack traffic?
    5·1 answer
  • The photographer for "The Migrant Mother" photograph used _______________, which is a technique that would be considered unethic
    8·2 answers
  • Greg works outside. He is often found cutting grass and making the local park grounds look nice for guests.
    10·1 answer
  • Who do you guys ship lol bit with?
    14·2 answers
  • which scheduling algorithm allocate the CPU firt to the process that request the CPU first, (a) first come first serve,(b) short
    9·1 answer
  • Pls awnser I will mark brainliest as soon as possible
    13·2 answers
  • I have a top-secret recipe for the greatest cookie dough I have made and I want to keep the recipe a secret so I apply for a? *
    15·1 answer
  • The Freeze Panes feature would be most helpful for which situation?
    6·1 answer
  • What is the datapath of add instruction?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!