All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Ask a Question
Search
Search
Sign In
Register
study help
computer science
programming principles and practice
Questions and Answers of
Programming Principles and Practice
What does vector alphabet(26); do?
How do you write a for-loop that prints every element of a vector?
What is the index of the third element of a vector?
What can you do to a string that you cannot do to an int?
Modify the program from exercise 19 so that when you enter an integer, the program will output all the names with that score or score not found.Dara from Exercise 19Write a program where you first
What can you do to an int that you cannot do to a string?
Modify the program from exercise 19 so that when you enter a name, the program will output the corresponding score or name not found.Dara from Exercise 19Write a program where you first enter a set
When should you define a separate function for part of a program? List reasons.
Write a program where you first enter a set of name-and-value pairs, such as Joe 17 and Barbara 22. For each pair, add the name to a vector called names and the number to a vector called scores (in
Describe what the line char foo(int x) means in a function definition.
Write a program to solve quadratic equations. A quadratic equation is of the formax2 + bx + c = 0If you don’t know the quadratic formula for solving such an expression, do some research. Remember,
How do you print the numeric value of a char?
Write a program that finds the min, max, and mode of a sequence of strings.
When should the for-loop be used and when should the while-loop be used?
In the drill, you wrote a program that, given a series of numbers, found the max and min of that series. The number that appears the most times in a sequence is called the mode. Create a program that
What is the function of each part of the header line in a for-loop, and in what sequence are they executed?
Write a program that takes an input value n and then finds the first n primes.
What are some common problems with switch-statements?
Modify the program described in the previous exercise to take an input value max and then find all prime numbers from 1 to max.Data from Previous ExerciseCreate a program to find all the prime
When would a programmer prefer a switch-statement to an if-statement?
Create a program to find all the prime numbers between 1 and 100. There is a classic method for doing this, called the “Sieve of Eratosthenes.” If you don’t know that method, get on the web and
What are some operators that can be used for strings?
Modify the program described in the previous exercise to take an input value max and then find all prime numbers from 1 to max.Data from Previous ExerciseCreate a program to find all the prime
What operators can be used on integers but not on floating-point numbers?
Create a program to find all the prime numbers between 1 and 100. One way to do this is to write a function that will check if a number is prime (i.e., see if the number can be divided by a prime
What are some operators that we can use for integers and floating-point values?
Write a program that plays the game “Rock, Paper, Scissors.” If you are not familiar with the game do some research (e.g., on the web using Google). Research is a common task for programmers. Use
What is a magic constant? Give examples.
Try to calculate the number of rice grains that the inventor asked for in exercise 8 above. You’ll find that the number is so large that it won’t fit in an int or a double. Observe what happens
What is a symbolic constant and why do we use them?
There is an old story that the emperor wanted to thank the inventor of the game of chess and asked the inventor to name his reward. The inventor asked for one grain of rice for the first square, 2
What is a literal?
Modify the “mini calculator” from exercise 5 to accept (just) single-digit numbers written as either digits or spelled out.Data from Exercise 5Write a program that performs as a very simple
What is a constant expression?
Make a vector holding the ten string values "zero", "one", . . . "nine". Use that in a program that converts a digit to its corresponding spelled-out value; e.g., the input 7 gives the output seven.
What is an lvalue? List the operators that require an lvalue. Why do these operators, and not the others, require an lvalue?
Write a program that performs as a very simple calculator. Your calculator should be able to handle the four basic math operations — add, subtract, multiply, and divide — on two input values.
What is the difference between a statement and an expression, as described in this chapter?
Write a program to play a numbers guessing game. The user thinks of a number between 1 and 100 and your program asks questions to figure out what the number is (e.g., “Is the number you are
What does an expression do?
Read a sequence of double values into a vector. Think of each value as the distance between two cities along a given route. Compute and print the total distance (the sum of all distances). Find and
What are the three requirements a programmer should keep in mind when expressing computations?
If we define the median of a sequence as “a number so that exactly as many elements come before it in the sequence as come after it,” fix the program in §4.6.3 so that it always prints out a
What do we mean by inputs and outputs to a computation? Give examples.
From a philosophical point of view, you can now do everything that can be done using a computer — the rest is details! Among other things, this shows the value of “details” and the importance
If you haven’t already, do the Try this exercises from this chapter.
What is a computation?
Define a rule to help decide if a conversion from one type to another is safe or unsafe.
Why can conversion from double to int be a bad thing?
What is type safety and why is it important?
What are some good rules for choosing names?
Give five examples of legal names that you shouldn’t use because they are likely to cause confusion.
Which of the following are legal names in C++? If a name is not legal, why not? This_little_pig latest thing This 1_is fine the_$12_method 2_For_1_special _this_is_ok MiniMineMine number correct?
What is string concatenation and how do you make it work in C++?
What is an initialization and how does it differ from an assignment?
What is a definition?
What measures do we use for the size of small entities in memory, such as ints and strings?
What are typical sizes for a char, an int, and a double?
Write a program that prompts the user to enter some number of pennies (1-cent coins), nickels (5-cent coins), dimes (10-cent coins), quarters (25-cent coins), half dollars (50-cent coins), and
Write a program that takes an operation followed by two operands and outputs the result. For example:+ 100 3.14* 4 5Read the operation into a string called operation and use an if-statement to figure
What kinds of literals are there?
What is a literal?
Write a program that converts spelled-out numbers such as “zero” and “two” into digits, such as 0 and 2. When the user inputs a number, the program should print out the corresponding digit.
Write a program to test an integer value to determine if it is odd or even. As always, make sure your output is clear and complete. In other words, don’t just output yes or no. Your output should
How would you writecout << "Hello, ";cout << fi rst_name;cout << "!\n";as a single line of code?
What terminates input into an integer?
Write a program that prompts the user to enter three integer values, and then outputs the values in numerical sequence separated by commas. So, if the user enters the values 10 4 6, the output should
What terminates input into a string?
What is \n called and what purpose does it serve?
Write a program that prompts the user to enter two integer values. Store these values in int variables named val1 and val2. Write your program to determine the smaller, larger, sum, difference,
If you want the user to input an integer value into your program for a variable named number, what are two lines of code you could write to ask the user to do it and to input the value into your
Write a program that doesn’t do anything, but declares a number of variables with legal and illegal names (such as int double = 0;), so that you can see how the compiler reacts.
Which operator do you use to read into a variable?
Write a program in C++ that converts from miles to kilometers. Your program should have a reasonable prompt for the user to enter a number of miles. Hint: There are 1.609 kilometers to the mile.
If you haven’t done so already, do the Try this exercises from this chapter.
What is meant by the term prompt?
Please don’t underestimate the importance of the notion of type safety. Types are at the center of most notions of correct programs, and some of the most effective techniques for constructing
If you understand everything in the textbook, why is it necessary to practice?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points
What is an IDE and what does it do for you?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the chapter. You may have to
What is the difference between a source file and an object file?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the
What does the linker do for your program?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the chapter. You may have to
What does a .h suffix at the end of a file name signify in C++?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the
What is the purpose of the #include directive?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the chapter. You may have to
Write a definition for each of the terms from “Terms.” First try to see if you can do it without looking at the chapter (not likely), then look through the chapter to find definitions. You might
What is the purpose of the compiler?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the chapter. You may have to refer
Find a good cookbook. Read the instructions for baking blueberry muffins (if you are in a country where “blueberry muffins” is a strange, exotic dish, use a more familiar dish instead). Please
In the “Hello, World!” program, what is the purpose of the line return 0;?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points
Write a description of how to get from the front door of your dorm room, apartment, house, whatever, to the door of your classroom (assuming you are attending some school; if you are not, pick
Name a function that must appear in every C++ program.The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the chapter. You may
Expanding on what you have learned, write a program that lists the instructions for a computer to find the upstairs bathroom, discussed in §2.1. Can you think of any more steps that a person would
Name the four parts of a function.The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the chapter. You may have to refer back
What’s so important about the “Hello, World!” program? Its purpose is to get us acquainted with the basic tools of programming. We tend to do an extremely simple example, such as “Hello,
Change the program to output the two linesHello, programming!Here we go!We list drills separately from exercises; always complete the chapter drill before attempting an exercise. Doing so will save
What is the purpose of the “Hello, World!” program?The basic idea of these review questions is to give you a chance to see if you have noticed and understood the key points of the chapter. You
What are some uses of software that make your life more difficult?
What are some uses of software that make your life easier?
Why can software development be difficult? List some reasons.
What are the stages of software development?
What does a software developer look like?
How much memory does your computer have? Main memory? Disk?
Showing 500 - 600
of 628
1
2
3
4
5
6
7