Would this code sequence compile? explain.

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

1. Consider the following sequence of C++ code

int age;
cout << "Please enter your age: "<<endl;
cin>> Age;

Would this code sequence compile? Explain.
Answer:

2. What does the following pseudocode do?

Input x
Input y
Set result = (x+y)/2
Output result
Answer:

3. Using pseudocode or C++, write the statements to enter an integer number, compute the number raised to power 5 and output the result.
Answer:

4. Using pseudocode or C++, write the statements to enter two integer numbers, switch their values and output the result.
Answer:

5. Using pseudocode or C++, write the statements to enter an integer number, determine if it is even or odd and print "The number is even" if it is even or "The number is odd" if it is odd
(Hint: the % operator returns the remainder of the division of a number by another. For example 5%2 returns 1 because the remainder of 5 divided by 2 is 1).
Answer:

Solution Preview

I have provided help and explanation for each of the questions you asked below. I've provided pseudocode in most cases since that might be easier for understanding the concepts.

----
6. Consider the following sequence of C++ code

int age;
cout << "Please enter your age: "<
cin>> Age;

Would this code sequence compile? Explain.
Answer:
----

This sequence would not compile. There are a couple of problems. First of all, the second statement has a trailing "<" that will cause a syntax error. That symbol should be a ;. All statements in C++ need to end in a ";" character.

Second, the third line is using a unknown variable. "Age" is not declared but "age" is. Notice that the first line of the sample code has "int age;". That declares a new integer variable named "age". Since C++ is case sensitive "age" is not the same as "Age". The first or third lines need to be edited to match each other.

----
7. What does the following pseudocode do?

Input x
Input y
Set result = (x+y)/2
Output result
Answer:
----

This bit of pseudocode reads in two ...

Reference no: EM13937094

Questions Cloud

How does the structure affect the function : Describe the structure of the cell wall and the cell membrane in plant cells and How does the structure affect the function?
Development of new efficient refineries : With the development of new efficient refineries in the Middle East and China, Western Oil companies are selling off their existing refining capacity .
Stationary points and any asymptotes showing : For the following function: y=(x+2)2+3/x2-1 Using calculus analyze the graph of the function detailing the important points such as the intercepts the stationary points and any asymptotes showing all your working and producing a..
Unconstrained maximization problem : Consider the maximization problem of f(x; y) subject to the constraint g(x; y) = c. Assume that (x; y) is a global maximum. Then rf(x; y) = rg(x; y) where  is the lagrange multiplier.
Would this code sequence compile? explain. : Using pseudocode or C++, write the statements to enter an integer number, compute the number raised to power 5 and output the result
Describe the structure and function of each tissue : Name two plant tissues in which dead cells are useful. Describe the structure and function of each tissue, showing how the dead cells contribute. Why couldn't animals make use of dead cells in the same way?
Compute the manufacturing overhead rate for the year : Ikerd Company applies manufacturing overhead to jobs on the basis of machine hours used. Overhead costs are expected to total $300,000.For the year, and machine usage is estimated at 125,000 hours. Compute the manufacturing overhead rate for the ye..
Strengths and weeknesses of group decision making : Build as essay constrsting the strengths and weeknesses of group decision making illustrating your support of your arguements (you may assume your own organization purpose 1000 words
Is return on investment a good performance measure to use : Is return on investment a good performance measure to use to evaluate him? Is return on investment a good measure to evaluate the economic viability of the Portimão Division? Explain.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Suggest an application system

Prompt for user login to begin using the system, provide an avenue for users to enter test data - Suggest an application system which is able to perform some arithmetic computations, like commission system, encryption system, timer system, etc, fro..

  Program to calculate the records in database

The O-So-Good Chocolate Company produces different types of chocolates daily. They need a little summary report that shows how much of each chocolate type they produce for a given month. This way they can plan next month's production schedule.

  Program prompts the user to input the height and the radius

Rearrange the statements so that the program prompts the user to input the height and the radius of the base of a cylinder and outputs the volume and surface area of the cylinder. Format the output to two decimal places.

  Make a c program that squares the number

Make a C program that accepts an integer value at the main method from the keyboard and in turn passes the value to a function that squares the number

  Load in the household configuration file

The first thing the program is required to do is load in the household configuration file, with the following  filename: housecfg.dat

  Implement the basic properties of a bank account

Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data:

  Write a program that draws a picture of a house

Write a program that draws a picture of a house. It could be as easy as the accompanying figure, or if you like, make it more elaborate (3-D, skyscraper, marble columns in the entryway, whatever).

  Grab the tokens from the token vector and find single quot

There is segmentation fault in this code and I don't know where or how to fix it. The purpose of this code right here is to grab the tokens from the token vecctor and find single quotes.

  C program that allows user to make some banking transactions

Write a C program that allows the user to make some banking transactions. The program should first prompt the user to enter the current balance of his/her bank account (in dollars and cents, not less than zero).

  Total cost for buying the books

Print out the title of the book. If a 20% discount is provided for buying the book, calculate and print out the discounted price for the book. Also, calculate and print out the total cost for buying the books at the discounted price.

  A charitable organization wants to design a special atm

A charitable organization wants to 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.   He/she can then retrieve up to $150 per day depending on..

  Consider implementing subnetting to support three department

Consider implementing subnetting to support three departments within an organization. The three departments P, Q and R need support for 30, 40 and 60 hosts.

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