Write a cpp program for magic number

Assignment Help C/C++ Programming
Reference no: EM13763088

Instructions

Ask the user to enter a "magic number," which is an integer between 0 and 9, inclusive.

Then, ask a user to enter 10 integers between 0 and 9, inclusive. (If a user enters an integer outside of that range, therefore invalid, notify the user of the error and ask for him/her to try again. Invalid numbers do not count towards the 10 valid integers requirement.)

NOTE: User input should be done in a repetition structure (loop). Ten sequential input statements will not satisfy the requirements of this assignment.

Your program should output the following:

How many times the user entered the magic number.

The average of all the valid numbers that the user entered.

Sample Output:

What is the "magic number?" 4

Enter a number from 0 to 9: 4

Enter a number from 0 to 9: 1

Enter a number from 0 to 9: 4

Enter a number from 0 to 9: 3

Enter a number from 0 to 9: 7

Enter a number from 0 to 9: 1

Enter a number from 0 to 9: 5

Enter a number from 0 to

Reference no: EM13763088

Questions Cloud

Algorithm attributes and their importance. : Write a 2 page research paper (excluding title and reference pages) on algorithm attributes and their importance. Use two resources (Wikipedia sources are not permitted) and list each resource used at the end of the paper in the reference list sec..
Function that returns a token when it is needed. : A major component of your assignment will be to write a procedure (Function) that returns a token when it is needed. Your lexer should return a record, one field for the token and another field the actual "value" of the token (lexeme), i.e. the in..
What were you most surprised to learn from the film : What were you most surprised to learn from the film? Why did the American government decide to assimilate Native American children into Western culture?
Ratio computations and effect of transactions : Presented below is information related to Carver Inc.
Write a cpp program for magic number : Ask the user to enter a "magic number," which is an integer between 0 and 9, inclusive. Then, ask a user to enter 10 integers between 0 and 9, inclusive. If a user enters an integer outside of that range, therefore invalid, notify the user of the ..
Write down the first order necessary conditions : Write down the Lagrangean for problem and Write down the first order necessary conditions (FOC) for a minimum.
What you have learned about children who are gifted : What you have learned about children who are gifted and talented. What are the special needs of young children who are gifted and talented? What are the special needs of older children?
Problems related to astronomy : What is the approximate wavelength of this signal?
Modify the inventory program to include an add button : Modify the Inventory Program to include an add button, a delete button, and a modify button on the GUI. These buttons should allow the user to perform the corresponding actions on the item name, the number of units in stock, and the price of each ..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Reads numbers from input and prints them in reverse order

Write a C program that reads ten numbers from input and prints them in reverse order. We assume that the data consists of integers. The program should conform to the following format:

  Write a c++ program that asks the user for a radius r

Write a c++ program that asks the user for a radius r. The program must include a function called calcwradius that accepts the value of the radius r, and calls the function pi shown below.

  Create class having constructor to recieve two ints

Create a class (in C++)named Card. The class should have two int data members named face and suit.The class should have a constructor that recieves the two ints and uses them to initialize the data members.

  The imperial system of measurements

The Imperial system of measurements uses feet and inches for length, where 1 foot is equal to 12 inches. Write a class named Imperial that will represent distance measurements in feet and inches. Your class should include the following.

  Provide a class diagram for every user authored class

Examine the sample code you have been provided with. This code is for a simple Car Hire management system. It contains a number of classes.

  Write a script that creates a craps game

Write a script that creates a craps game and meets the following requirements. Name the script craps.sh The script will get 2 random numbers between 1-6.

  Create a calling module name and parameters

Create a calling module name and parameters for the following. (Remember that the asterisk before the parameter name indicates a call-by-reference parameter.

  Show how your function works

Write a function named longestSortedSequence that accepts an array of integers as a parameter and that returns the length of the longest sorted non-decreasing sequence of integers in the array. For case given the sequence:

  Design a special atm machine

design a special ATM machine to be used by needy people -  The association supplies the needy person with a pin number to be able to use the ATM machine.

  Prompts the user to enter the mass of a person

Write a program that prompts the user to enter the mass of a person in kilograms and outputs the equivalent weight in pounds. Output both the mass and the weight rounded to two decimal places

  Prepare a linux shell

Prepare a linux shell (in other words, write a C/C++ program) that will recursively prompt for input from the user. The shell should prompt as

  Write a program that prompts the user to input

One metric ton is approximately 2205 pounds. Write a program that prompts the user to input the amount of rice, in pounds, in a bag. The program outputs the number of bags needed to store one.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd