What input parameters the function takes

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

C++ Homework

1. What are the two types of comment styles in C++?

2. Find 3 errors in the following program

// This is a little program

that calculates a modulus answer.

int main()

{

   double x,y,answer;

   answer = x%y;

   cout << "\n\n answer = << answer;

   return 0;

     }

3. What output is generated from running the following program?

#include <iostream>

using namespace std;

void Red();

int main()

{

      int i = 1;

      while(i < 4)

      {

            Red();

            ++i;

      }

}

void Red()

{

      cout << "\nRed is a great color.";

}

4.  Salma wrote the following program:

#include <iostream>

#include <cmath>

using namespace std;

int main()

{

      float square;

      float x = static_cast<float>(- 3.7755);

      square = x * x;

      cout << "The square of " << x;

      cout << "\nis equal to " << square << endl;

      system("pause"); // so that the screen stays up till user hints a key

      return 0;

}

Salma wants to put the underlined C++ code (above) in a separate function and wants to call it squareIt. Put the above code in a MS Visual Studio C++ project. Compile it and make sure it compiles fine and runs correctly.

What you are required to do:

Rewrite Salma's program by creating the function squareIt(). Call the function squareIt() from within the main() function. Recompile the code and make sure it compiles and runs fine and produces the same results.

When you create the function think about

1.  What the function will do

2.  what input parameters the function takes.

3.  What results it returns to the calling program.

4.  How it is called in the main.

5.  Do not forget to create a prototype for it at the top of the program.

Reference no: EM13968855

Questions Cloud

What are the advantages for a donor of participating : What types of recipient organizations are best-suited to SVP-type funding? If all Philanthropy were to move to this model, would any nonprofits be hurt?
What is the internal rate of return : Calculate the Net Present Value for the capital budgeting proposal - What is the Payback in years - What is the (IRR) Internal Rate of Return?
Appropriate testing hypothesis problem : Formulate the appropriate testing hypothesis problem and carry out the test if a = 0.05.
Design a table describing the dimensions of culture : Design a table describing the five dimensions of culture proposed by Hofstede. Include the managerial implications of these dimensions and a comparison of Hofstede's findings with those of Trompenaars' and the GLOBE project team
What input parameters the function takes : What input parameters the function takes.  What results it returns to the calling program.  How it is called in the main.  Do not forget to create a prototype for it at the top of the program.
Describe the type of business you have created : The product or service, and general staffing plan. Provide a rationale for your plan.
Determine the timing a pendulum swing or a drop time : What do you conclude about the accuracy of your measurement technique - Define uncertainties Are they SD, SEM or confidence intervals? Always state the sample size.
What is the main advantage of the micro-kernel approach : What is the main advantage of the micro-kernel approach to system design? How do user programs and system services interact in a micro-kernel architecture?
What happens if you delay start of savings for 5 years : Once you add up all the future values from step 2 above, and do a time line to determine how much you will be able to spend each year assuming you are going to spend all your money

Reviews

Write a Review

C/C++ Programming Questions & Answers

  State fair pie eating contest all contestants

At the State Fair Pie Eating Contest all contestants in the heavyweight division must weigh within 130 pounds to 250 pounds. Write a program that asks for a contestant's weight and then says if the contestant is allowed in the contest.

  Write a function to convert the two dimensional coordinates

Write a function to convert the two dimensional coordinates of a point from Cartesian system to polar system by using x and y as its parameters, returning r and using references to pass theta value.

  Explain shortestpath() and printshortestdistance()

Explain the following code line by line, and submit your answer: shortestPath() & printShortestDistance() in weightedGraph.h

  An arithmetic expression

The statements of that expression language consist of an arithmetic expression followed by a list of assignments. Assignments are separated from the expression and each other by commas. A semicolon terminates the expression. The arithmetic expr..

  Set of integer numbers and another single number

Write an algorithm called locate (with running time log n, that accept a set of integer numbers and another single number and finds out whether the number is found in the set of integers. If it exist, it should print its index in the list otherwis..

  Weather balloons are used to gather temperature

Weather balloons are used to gather temperature and pressure data at various altitudes in the atmosphere.  The balloon rises because the density of the helium in the balloon is less than the density of the surrounding air outside the balloon.  As the..

  Write a program in which the program print out the input

use (switch statement) to write a program in which the program print out the input (single character) if the character is not '2','t', or 'w'. Use 'default' and 'break' wisely.

  Program that reads in the average monthly

Write a program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months. The program then prints out a nicely formatted table showing the rainfa..

  Define two derived classes of the abstract class

Define two derived classes of the abstract class ShapeBase below. Your two classes will be called RightArrow and LeftArrow. These classes will draw arrows that point right and left,

  The relative strengths of acids and bases table

List, in a general way, the information that is provided in the Relative Strengths of Acids and Bases table. Explain how the information in the Relative Strengths of Acids and Bases table is used to support your work in this unit. Use examples to su..

  Program to find the factors

Write a c++ program to find the factors of an integer (entered by the user) which are themselves squares.

  What are abstract classes

What are abstract classes

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