Question: can someone do this for me ? Exercises At the end of each chapter, we include exercises you can do with the things you've learned.
can someone do this for me ?
Exercises
At the end of each chapter, we include exercises you can do with the things you've learned. We encourage you to at least attempt every problem. You can't learn to program only by reading about it; you have to practice.
Before you can compile and run C++ programs, you might have to download and install a few tools. There are many good options. We recommend either Visual Studio Community 2017 if you are working in the Windows operating system or Code::Blocks for all operating systems. Instructions for installing these programming environments are in Appendix A.
The code for this chapter is in the ch01 directory of ThinkCPPCode. See "Using the Code Examples" on page xx for instructions on how to download the repository. Before you start the exercises, we recommend that you compile and run the examples.
Exercise 1-1. Computer scientists have the annoying habit of using common English words to mean something other than their common English meaning. For exampe, in English, statements and comments are the same thing, but in programs they are different.
In computer jargon, what is the difference between a statement and a comment?
What does it mean to say that a program is portable?
In common English, what does the word compile mean?
What is an executable? Why is that word used as a noun?
The glossary at the end of each chapter is intended to highlight words and phrases that have special meanings in computer science. When you see familiar words, don't assume that you know what they mean!
Exercise 1-2.
Before you do anything else, find out how to compile and run a C++ program. Some environments provide sample programs similar to the example in "The Hello World! Program" on page x.
Type in the hello world program, then compile and run it.
Add an output statement that displays a second message after the "Hello, World!". Say something witty like, "How are you?" Compile and run the program again.
Add a comment to the program (anywhere), recompile, and run it again. The new comment should not affect the result.
This exercise may seem trivial, but it is the starting place for many of the programs we will work with. To debug with confidence, you will need to have confidence in your programming environment.
In some environments, it is easy to lose track of which program is executing. You might find yourself trying to debug one program while you are accidentally running another. Adding (and changing) output statements is a simple way to be sure that the program you are looking at is the program you are running.
Exercise 1-3.
It is a good idea to commit as many errors as you can think of, so that you see what error messages the compiler produces. Sometimes the compiler tells you exactly what is wrong, and all you have to do is fix it. But sometimes the error messages are misleading. Over time you will develop a sense for when you can trust the compiler and when you have to figure things out yourself.
Starting with the hello world program, try out each of the following errors. After you make each change, compile the program, read the error message (if there is one), and then fix the error.
Remove one of the open curly braces.
Remove one of the close curly braces.
Instead of main, write mian.
Remove the word int.
Remove the word main.
Replace cout with Cout.
Remove the <<. Add an extra one << <<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
