Write a complete function that will change the value

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

Question 1

- Write a function called setToValue( ... ) that will work with the following section of code.
- You need to write a complete function that will change the value of the first parameter passed into it to the value of the second parameter.
- It only needs to work with double types, nothing else.
- You don't need to put in the prototype
- Only turn in the function you have written, NOT THE WHOLE PROGRAM.
#include <iostream>
using namespace std;
// assume your answer put is here so you don't need a
// prototype declaration

// nothing in main() can change!
int main()
{
double weight, height, pi, avagadrosNumber;

// here are some possible calls to the function you need to write
setToValue(height, 65.7);
setToValue(weight, 210);
setToValue(pi, 3.14156);
setToValue(avagadrosNumber, 6.02e-23);

// here's the code that tests the above calls
cout<< "This should be 65.7 --> " << height <<endl;
cout<< "This should be 210 --> " << weight <<endl;
cout<< "This should be 3.14156 --> " << pi <<endl;
cout<< "This should be 6.02e-23--> " <<avagadrosNumber<<endl;
}

Question 2

- Write a function called countGenerator( ... ) that will work with the following section of code.
- It will take a string parameter and return an integer accord to the following rules:
- If the string passed to it is exactly "Red", the function will return a random number from 1 to 4.
- If the string passed to it is exactly "Blue", the function will return a random number from 1 to 6.
- If the string passed to it is exactly "Green", the function will return a random number from 1 to 8.
- If the string passed to it is anything else, the function will return a 0 (zero).
- You don't need to put in the prototype.
- Only turn in the function you have written, NOT THE WHOLE PROGRAM!
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
// assume your answer is here so you don't need a
// prototype declaration// nothing in main() can change!
intmain()
{
// seed the random number generator
srand(time(0));

// test "Red" parameter
cout<< "I will now print 20 numbers from 1 to 4:" <<endl;
for (inti=0;i<20;i++)
{
cout<<countGenerator("Red") << " ";
}
cout<<endl;

// test "Blue" parameter
cout<< "I will now print 20 numbers from 1 to 6:" <<endl;
for (inti=0;i<20;i++)
{
cout<<countGenerator("Blue") << " ";
}
cout<<endl;

// test "Green" parameter
cout<< "I will now print 20 numbers from 1 to 8:" <<endl;
for (inti=0;i<20;i++)
{
cout<<countGenerator("Green") << " ";
}
cout<<endl;

// test the returning a zero if the name isn't valid
cout<< "I will now print 5 zeros:" <<endl;
cout<<countGenerator("green") << " ";
cout<<countGenerator("red") << " ";
cout<<countGenerator("blue") << " ";
cout<<countGenerator("BLUE") << " ";
cout<<countGenerator("") << " ";
cout<<endl;
}

Question 3

- Write a function called divisors( ... ) that will work with the following section of code.
- It will take three integer parameters and return nothing.
- The first pararmeter is the number we are looking for divisors of.
- The second parameter is where to start looking
- The third parameter is where to stop looking. This number is included in the checking for divisors!
- It will print a list of all the divisors of the first number that are between the second and third parameter. (Include those parameters in the check.)
- Print the numbers out with a single space between them.
- If there are no divisors, nothing will be printed.
- The third parameter will always be greater than the second parameter, so you can check from low to high numbers.
- You can use the % operator to determine if one number is a divisor of another.
- Something is a divisor when there is a remainder or zero when they are divided.
- You don't need to put in the prototype
- Only turn in the function you have written, NOT THE WHOLE PROGRAM!
#include <iostream>
using namespace std;
// assume your answer is here so you don't need a
// prototype declaration

// nothing in main() can change!
int main()
{
cout<< "Divisors of 12 from 1 to 10 ";
cout<< "(should be 1 2 3 4 6)";
divisors(12, 1, 10);
cout<<endl;

cout<< "Divisors of 24 from 6 to 12 ";
cout<< "(should be 6 8 12)";
divisors(24, 6, 12);
cout<<endl;

cout<< "Divisors of 100 from 26 to 49 ";
cout<< "(nothing should be printed )";
divisors(100, 26, 49);
cout<<endl;
}

Reference no: EM131743060

Questions Cloud

Replace the first ball before drawing the second : You draw two balls from the urn, but replace the first ball before drawing the second. Find the probability that the first ball drawn is red and the second
Discuss the day the cisco kid shot john wayne : Discuss the coming of age theme in two of the following stories: Nash Candelaria's "The Day the Cisco Kid Shot John Wayne
What is the mean difference in weights of the melons : Picking melons. Two stores sell watermelons. At the first store the melons weigh an average of 22 pounds, with a standard deviation of 2.5 pounds.
How does hemingway highlight nick''s mental condition : Discuss the groups represented there. To use an example from a prior week, we looked at Jackson Jackson's status as Native American
Write a complete function that will change the value : Write a complete function that will change the value of the first parameter passed into it to the value of the second parameter
What program help achieve values-driven culture of integrity : Include any insights from your professional experience. What programs or processes help achieve a values-driven culture of integrity?
Discuss about the low level of homeownership in the city : Home, sweet home. According to the 2000 Census, 66% of U.S. households own the home they live in. A mayoral candidate conducts a survey of 820 randomly.
Discuss an emerging marketing trend that may affect business : Compare and contrast how culture is likely to impact domestic marketing strategies versus what the company may encounter .
Analyze what is the purpose of a code of conduct : Answer the following questions: Analyze what is the purpose of a code of conduct? Why is it important for a company to have a written code of conduct?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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