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
DIA [1.3K]
3 years ago
11

g 1. Write a program that asks the user for a number greater than 5 and prints all values between 1 and n that are multiples of

5 (i.e. evenly divisible by 5). 2. Write a program that prompts the user for an integer n between 1 and 100. If the number is outside the range, it should keep asking the user for a valid number. The program computes and prints at the end two things: a.The sum of the numbers from 1 to n. b.The average of the numbers from 1 to n.
Computers and Technology
1 answer:
a_sh-v [17]3 years ago
5 0

PROGRAM 1

#include <iostream>  

using namespace std;

int main() {

   int n;

   // user input taken for n

   cout<<"Enter any number greater than five: ";

   cin>>n;

   

   cout<<"The multiples of 5 between 1 to "<<n<<" are shown below."<<endl;

   

   // displaying multiples of 5 between 1 to n

   for(int h=1; h<=n; h++)

   {

       // if number is completely divisible by 5, remainder will be 0

       if( (h%5)==0)

           cout<<h<<endl;

   }

 

   return 0;

}

OUTPUT

Enter any number greater than five: 22

The multiples of 5 between 1 to 22 are shown below.

5

10

15

20

The program does not implements any input validation since this is not mentioned in the question.

User input is taken. All the multiples of 5 computed inside a for loop, and displayed to the console.

PROGRAM 2

#include <iostream>

using namespace std;

int main() {

   // variables to hold respective values

   int n;

   int sum=0;

   double avg=0;

   

   do

   {

       // user input taken for n

       cout<<"Enter any number between 1 and 100: ";

       cin>>n;

       if(n<1 || n>100)

           cout<<"Invalid number. Enter valid number."<<endl;

       cout<<""<<endl;

       

   }while(n<1 || n>100);

   

   // computing sum and average of numbers from 1 to n

   for(int h=1; h<=n; h++)

   {

       sum = sum+h;

   }

   

   avg=avg+(sum/n);

   

   cout<<"Sum of all the numbers from 1 to "<<n<<" is "<<sum<<endl;

   

   cout<<""<<endl;

   cout<<"Average of all the numbers from 1 to "<<n<<" is "<<avg<<endl;

   

   return 0;

}

OUTPUT

Enter any number between 1 and 100: 111

Invalid number. Enter valid number.

Enter any number between 1 and 100: 0

Invalid number. Enter valid number.

Enter any number between 1 and 100: 23

Sum of all the numbers from 1 to 23 is 276

Average of all the numbers from 1 to 23 is 12

The program not implements any input validation since this is mentioned in the question.

User input is taken inside do-while loop till valid input is obtained.

The sum of all numbers from 1 to n computed inside a for loop, average computed outside for loop.

Both values are displayed to the console.

You might be interested in
You want to allow members of the users group to use fdisk on the /dev/sda drive (and only that drive) and to use the yum command
masya89 [10]

Answer:

su ,sg and sudo command.

Explanation:

Whenever the user needs to enable workgroup mates should use fdisk including just that disk on both the /dev / sda disk, using the following command to update and configure the following packages. Thus he uses the command su, sg, and sudo.

So, the following commands are required according to the following statement.

6 0
3 years ago
What two devices in a computer should be considered "black boxes," and should never be opened due to risks involving charged cap
NNADVOKAT [17]

The two devices in a computer that should be considered "black boxes," and should never be opened due to risks involving charged capacitors are MONITOR and POWER SUPPLY.

Explanation:

  • Physical contact or close proximity to the open power supply caused a discharge from the capacitor that resulted in an electric shock. Capacitors can discharge current even when not energized because they hold a charge for some time after the power is turned off.
  • To do harm to your body, the voltage across the capacitor's terminals must be high enough to cause a harmful effect on you. There are no hard rules for at what voltage things become harmful, but a common 'rule of thumb' is that DC up to 48 Volt is considered low voltage. So a capacitor charged to a voltage below 48 V is fairly safe.
  • A charged capacitor can be very dangerous, so it's important that you avoid coming into contact with the terminals at all times.
3 0
3 years ago
A user reports that a PC gets a BSOD on startup. A technician has researched the error message and found a driver to replace. Wh
7nadin3 [17]

Answer:

The explanation of this question is given below in the explanation section. however, the correct option of this question is "Boot the machine into safe mode"

Explanation:

BSOD error on startup

Blue screen of death error arises mostly when dirver produce fault into system or did not install properly. however, the correct option for this question, if PC gets BSOD error on startup then it is the best option for technician to remove the hardware that is recently installed and/or try to boot the machine into safe mode, then uninstall the driver that causing error on startup.

BSOD error occur during running the program on PC

However, if PC get BSOD during running program, then the best option for technician is to restart the machine and then install the driver properly. During this operation, as error occured, you may loss the data becuase you have no other option to save the data of program that is running.

6 0
3 years ago
When keying, keep fingers curved and upright over the home keys.<br> False<br> True
Dmitry [639]

Answer:

This is true.

Explanation:

I think everyone was taught to to type correctly sometime in school or at home. It helps you proficiently type. But most people don't use the Home Room Key Technique. Most use the "Chicken peck"

3 0
3 years ago
Which statement describes a difference between front-end and back-end databases?
Westkost [7]

Answer:

So a statement could be the front-end is what we see and the back-end is what we don't see, the behind the scenes. Like a play, we see the characters and them acting out a story but we dont see who is doing the lights, playing the music, fixing the costumes and makeup etc..

Explanation:

The term front-end means interface while the term back-end means server. So imagine you go on your social media app, what you can see like your friends list and your account and the pictures you post, who liked the pictures and all of that is called the front-end and is what <em>you</em> as a user can interact with; front-end development is the programming that focuses on the visual aspect and elements of a website or app that a user will interact with its called in other words the client side. Meanwhile, back-end development focusing on the side of a website users can't see otherwise known as the server side, its what code the site uses and what it does with data and how a server runs and interacts with a user on whatever device surface they're using.

6 0
1 year ago
Read 2 more answers
Other questions:
  • The fast food restaurant Chipotle pulled its app from Apple's app store when customer demand caused the firm's servers to crash.
    14·1 answer
  • The first computer (the eniac was how big
    8·1 answer
  • How does technology improve productivity at home? (Select all that apply.)
    5·1 answer
  • What type of network is capable of delivering voice, video streams, text, and graphics between many different types of devices o
    15·1 answer
  • Which type of optical scanner works in a manner similar to a copy machine?
    15·1 answer
  • <img src="https://tex.z-dn.net/?f=6.372%20%5Ctimes%2075%20find%20the%20product" id="TexFormula1" title="6.372 \times 75 find the
    6·1 answer
  • What are 3 ways to select an entire document?
    15·1 answer
  • A carver begins work on the following block of granite that weighs 2700 g. What is the density of the granite?
    13·1 answer
  • Full from of tmc computer
    8·2 answers
  • How does the quantity of data affect the accuracy of an experiment?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!