C++ for dummies pdf download
It is far too easy to access uninitialized array elements thinking that they are valid values. Fortunately, a small array may be initialized at the time it is declared.
The number of initialization constants can determine the size of the array. For example, you could have determined that floatArray has five elements just by counting the values within the braces. The following declaration is identical to the preceding one. For example, the following initializes all 25 locations in floatArray to 1. Most program languages start with an offset of 1 as well.
That makes the last element of a integer array integerArray[] and not integerArray[]. Reading from integerArray[] will return some unknown and unpredictable value. On the other hand, it might overwrite some data, thereby confusing the neighbor and making the program act in a seemingly random fashion.
Or it might crash the program. This is one integer beyond the end of the array. True, this version can replay its input by displaying the set of input numbers before calculating their sum, but this feature hardly seems earth shattering.
Yet, the ability to redisplay the input values hints at a significant advantage to using arrays. Arrays allow the program to process a series of numbers multiple times. The main program was able to pass the array of input values to displayArray for display and then repass the same numbers to sumArray for addition.
Some applications require sequences of sequences. A classic example of this matrix configuration is the spreadsheet. Laid out like a chessboard, each element in the spreadsheet has both an x and a y offset. In other words, intMatrix is a element array, each element of which is a 5-int array. As you might expect, one corner of the matrix is in intMatrix[0][0], while the other corner is intMatrix[9][4].
Whether you consider intMatrix to be 10 elements long in the x dimension and in the y dimension is a matter of taste. Using Arrays of Characters The elements of an array are of any type. Arrays of floats, doubles, and longs are all possible; however, arrays of characters have particular significance.
Creating an array of characters Human words and sentences can be expressed as an array of characters. This array is passed to the function displayCharArray along with its length. The displayCharArray function is identical to the displayArray function in the earlier example program except that this version displays chars rather than ints. This program works fine; however, it is inconvenient to pass the length of the array around with the array itself.
Creating a string of characters In many cases, all values for each element are possible. The displayString program iterates through the character array until a null character is encountered. The function displayString is simpler to use than its displayCharArray predecessor because it is no longer necessary to pass along the length of the character array. A string of characters is a null terminated character array.
Remember that zero is the only numeric value that converts to false; all other values translate to true. The prefix sz stands for zero-terminated string. A few of these functions are listed in Table Returns a zero if the two strings match exactly. The ANSI standard suggests that you use the string type as defined in the next section. However, you will see a large number of programs that continue to use these functions.
The following Concatenate program inputs two strings from the keyboard and concatenates them into a single string. The arguments to the str For example, the function strncat target, source, count tacks the second string source onto the end of the first argument target. An example output from the program appears as follows: Enter string 1:Chester Enter string 2:Dog Chester - Dog Press any key to continue.
The program begins by reading a string from the keyboard. Characters up to the first whitespace are read, the whitespace character is tossed, and www. This causes a dangerous overflow condition that hackers can and will exploit to put a virus in your program.
For example, the function getline inputs a line of text; however, this function accepts the length of the string as one of its arguments: cin. The strncpy and strncat functions accept the length of the target buffer as one of their arguments. I use the term string to refer to an array of characters terminated by a null and string type to refer to the type string.
The string type based StringConcatenate program appears as follows: www. The StringConcatenate program manipulates the string type variables as it would any other. Notice that some operations have to be understood in a slightly different way from their arithmetic equivalent. Operations on string type variables are defined in the string include file.
The string class is discussed further in Chapter This chapter introduces the pointer variable type. Memory is measured in bytes or bits. For example, you may find that an int is smaller than a long. The sizes output by the VariableSize program are typical for a bit processor such as the Pentium class processors.
A variable intReader might be at address 0x, whereas floatReader might be over at location 0x By convention, memory addresses are expressed in hexadecimal.
Of course, intReader and floatReader might www. This is somewhat analogous to a hotel. When you make your reservation, you may be assigned room 0x I know that suite numbers are normally not expressed in hexadecimal, but bear with me. Your buddy may be assigned 80 doors down in room 0x Each variable is assigned an address when it is created more on that later in this chapter when we talk about scope. Address Operators The two pointer-related operators are shown in Table Your results may vary.
The absolute address of program variables depends on a lot of factors. Notice how the variable n is exactly 4 bytes from the first variable declared m2.
The variable l appears 4 bytes down from that. The double variable d is a full 8 bytes from its neighboring variable f. Using Pointer Variables A pointer variable is a variable that contains an address, usually the address of another variable.
Returning to my hotel analogy for a moment, I might tell my son that I will be in room 0x on my trip. My son is a pointer variable of sorts. The next statement declares the variable pintVar to be a variable of type pointer to an int.
By the way, pintVar is pronounced pee-int-Var, not pint-Var. Thus, they would say splat pintVar. Many programmers adopt a naming convention in which the first character of the variable name indicates the type of the variable, such as n for int, d for double, and so on. A further aspect of this naming convention is to place a p at the beginning of a pointer variable name. Thus, we would read the first assignment as store the address of intVar in pintVar.
To make this more concrete, assume that the memory for function fn starts at location 0x In addition, assume that intVar is at address 0x and that pintVar is at 0x The layout here is simpler than the actual results from the Layout program; however, the concepts are identical. Your house has a unique address. Each byte in memory has an address that is unique.
A house address is made up of both numbers and letters. For example, my address is Main Street. You can store a couch in the house at Main Street — you can store a number in the byte located at 0x You can now store a couch at the house with the address written on the piece of paper.
Assign the address of myHouse to the House pointer, houseAddress. Now store a couch at the house located at the address stored in houseAddress. Assign the address of myInt to the pointer intAddress.
Finally, assign 10 to the int that intAddress points to. Using different types of pointers Every expression has a type as well as a value. This is equivalent to saying that, if houseAddress is the address of a house, the thing pointed at by houseAddress must be a house. Amazing, but true. That is, an address on a Pentium is 4 bytes long, period. Matching pointer types is extremely important.
Save a variable into an area of the wrong size, and nearby variables can be wiped out. This is demonstrated graphically in the following LayoutError program.
The assumption made here is that these three variables are laid out next to each other. The next three executable lines output the value of the three variables.
Not surprisingly, all three variables display as 0. After assigning the double value The variable hotelAddress is a pointer to a hotel. Now, the house address is cast into the address of a hotel and saved off into the variable hotelAddress. Finally, TheRitz is plopped down on top of my house. The type of pointer saves the programmer from stuffing an object into a space that is too big or too small.
Passing Pointers to Functions One of the uses of pointer variables is in passing arguments to functions. To understand why this is important, you need to understand how arguments are passed to a function. Passing by value You may have noticed that it is not normally possible to change the value of a variable passed to a function from within the function. Consider the following example code segment: www.
The value of n1 is then passed to fn. Upon entering the function, intArg is equal to 10, the value passed. Perhaps surprisingly, upon returning to parent , the value of n1 is still 0. That is, the expression is evaluated, even if it is just a variable name, and the result is passed. The significance of this difference is apparent when you consider the assignment within fn. Upon returning to parent , the value of n is 10 because n is just another name for 0x In the following example, the variable n is passed by reference.
The fn function stores the value 10 into int location referenced by intArg. Notice that reference is not an actual type. Making Use of a Block of Memory Called the Heap The heap is an amorphous block of memory that your program can access as necessary. This section describes why it exists and how to use it. Managed programs rely upon the.
NET framework. This book only covers unmanaged mode programming. In order to understand the dangers, you must know something about variable scope. Besides being a mouthwash, scope is the range over which a variable is defined. The function main immediately invokes parent. At that point, intParent goes into scope — that is, intParent is defined and available for the remainder of the function parent.
The second statement in parent is the call to child. Once again, the function child declares a local variable, this time intChild. The variable intChild is within the scope of child. When child exits, the variable intChild goes out of scope.
Not only is intChild no longer accessible, but it no longer even exists. The memory occupied by intChild is returned to the general pool to be used for other things.
As parent continues executing, the variable intLater goes into scope at the declaration. At the point that parent returns to main , both intParent and intLater go out of scope. The programmer may declare a variable outside of any function. This type of variable, known as a global variable, remains in scope for the duration of the program. Because intGlobal is declared globally in this example, it is available to all three functions and remains available for the life of the program.
Thus, by the time the memory address www. This error is very common because it can creep up in a number of different ways. Unfortunately, this error does not cause the program to instantly stop. In fact, the program may work fine most of the time — that is, the program continues to work as long as the memory formerly occupied by dLocalVariable is not reused immediately.
Such intermittent problems are the most difficult ones to solve. What is needed is a block of memory controlled by the programmer. Such a block of memory is called the heap. Heap memory is allocated using the new command followed by the type of object to allocate. For example, the following allocates a double variable off the heap.
After the function is finished with the memory location, it is returned to the heap. The function parent sets the pointer to zero after the heap memory has been returned — this is not a requirement, but a very good idea.
A program that crashes immediately upon encountering an error is much easier to fix than one that is intermittent in its behavior. NET—managed mode. NET programs. The concept of pointer variables is introduced in Chapter 8. Defining Operations on Pointer Variables Some of the same operators I cover in Chapter 3 can be applied to pointer types.
This section examines the implications of applying these operators to both to pointers and to the array types I discuss arrays in Chapter 7. Table lists the three fundamental operations that are defined on pointers. The real estate memory model which I use so effectively in Chapter 8, if I do say so myself is useful to explain how pointer arithmetic works. Consider a city block in which all houses are numbered sequentially. Extending this concept one step further, it makes no sense to add Main Street to Main Street.
Re-examining arrays in light of pointer variables Now return to the wonderful array for just a moment. An array is just like my city block. Each element of the array corresponds to a house on that block. Say that the house right on the corner is Main Street, which means that the house one house from the corner is Main Street, and so on. Take that same model back to the world of computer memory.
Consider the case of an array of 32 1-byte characters called charArray. If the first byte of this array is stored at address 0x, the array will extend over the range 0x through 0x12f.
Take this model one step further to the world of pointer variables. The addition of an integer offset to a pointer is defined such that the relationships shown in Table are true. Table also demonstrates why adding an offset n to ptr calculates the address of the nth element in charArray. That is, the name of an array without a subscript present is the address of the array itself.
The function then loops through each element of the array. On each loop, displayArray outputs the current integer that is, the integer pointed at by pArray before incrementing the pointer to the next entry in intArray. The use of pointers to access arrays is nowhere more common than in the accessing of character arrays. Expanding pointer operations to a string A null terminated string is simply a character array whose last character is a null.
This null terminated array serves as a quasi-variable type of its own. See Chapter 7 for an explanation of string arrays.
The following code examples compare this technique to the earlier technique of indexing in the array. Character pointers enjoy the same relationship with a character array that any other pointer and array share. The for loop chosen stops when the index reaches 5, the length of the string.
The second loop displays the same string using a pointer. The program sets the variable pszString equal to the address of the first character in the array. It then enters a loop that will continue until the char pointed at by pszString is equal to false — in other words, until the character is a null. The integer value 0 is interpreted as false — all other values are true.
The answer is partially pre- historic and partially human nature. These compilers could not perform the complicated optimizations that modern compilers can. In the old days of C, saving a few computer instructions was a big deal. This gave C a big advantage over other languages of the day, notably Fortran, which did not offer pointer arithmetic. After all, a char occupies a single byte. If szTarget is stored at 0x, the sixth element is located at 0x Once again, the dusty old house analogy works here as well.
I mean dusty analogy, not dusty house. Contrasting a pointer with an array There are some differences between indexing into an array and using a pointer. This problem is not generally a problem of the processor or the operating system but of the application. A second difference between a pointer and the address of an array is the fact that charArray is a constant, whereas pArray is not. Arrays of pointers are a type of array of particular interest. Just as arrays may contain other data types, an array may contain pointers.
The following declares an array of pointers to ints: www. The following two examples show why arrays of character strings are useful. Utilizing arrays of character strings Suppose I need a function that returns the name of the month corresponding to an integer argument passed to it. The month 0 is assumed to be invalid as are any numbers greater than A more elegant solution uses the integer value for the month as an index into an array of pointers to the names of the months.
If nMonth is valid, the function uses it as an offset into an array containing the names of the months. This technique of referring to character strings by index is especially useful when writing your program to work in different languages.
For example, a program may declare a ptrMonths of pointers to Julian months in different languages. The program would initialize ptrMonth to the proper names, be they in English, French or German for example at execution time. These strings contain the arguments to the program.
These arguments are also known as parameters. There is an exact Windows analog that will appear here in just a second. The first argument is an int that I have been calling quite descriptively, as it turns out nNumberofArgs.
The first argument is the name of the program. Thus, pszArgs[0] points to PrintArgs. The remaining elements in pszArgs point to the program arguments. The element pszArgs[1] points to arg1, and pszArgs[2] to arg2, for example. Select Parameters under the Debug menu. The program output appears as it would from the DOS prompt. Accessing program arguments Windows-style Windows passes arguments as a means of communicating with your program as well.
Try the following experiment. Find the executable file using Windows Explorer. Select multiple file names by clicking several files while pressing the Ctrl key or by using the Shift key to select a group. The name of each file appears as output. Notice that the name of each file appears as a single argument, even though the file name may include spaces. Also note that Windows passes the full pathname of the file. Using the drag-and-drop feature is an easy way to pass arguments to your program at startup.
That leaves you with two alternatives: You can give up on programming now while you still have a chance, or you can find and fix your errors. In this chapter, you find out how to track down and eradicate software bugs. Compile-time errors are relatively easy to fix because the compiler generally points you to the problem. These are known as run-time errors.
You can use two different techniques for finding bugs. You can add output statements at key points. A second approach is to use a separate program called a debugger. I cover both of these debugging techniques in this chapter.
Unfortunately, the program contains two errors, one that makes the program crash and one that causes the program to generate incorrect results.
The following steps route out the problem. I enter my trusty 1, 2, and 3 followed by —1, but get quite a shock when the nasty message shown in Figure appears instead of the expected average. Figure The initial version of Error Program terminates suddenly instead of generating the expected output. Fortunately, the first line of the error message is descriptive of the problem.
The message also spits out the memory address where the division occurred, but this is of little use because you have no idea where in the program that address may be. That happens a lot more often than you might think. The CPU may just happen to execute a divide instruction with a denominator of zero, thereby generating a divide by zero error message and masking the source of the problem.
I feel reasonably certain that at the time of the division, nNums must have been equal to zero. Clearly nNums should have been incremented during each loop of the input section. The output shown here includes a ridiculous value for average: This program generates incorrect results Enter another number:1 Enter another number:2 Enter another number:3 Enter another number Average is: Press any key to continue To get any farther, you need to know the value of these variables.
In fact, it would help to know the value of nValue as well because nValue is used to calculate nSum. The result of executing the program with the now standard 1, 2, 3, and —1 input is shown next. Even on the first loop, the value of nSum is unreasonable. In fact, at this point during the first loop, the program has yet to add a new value to nSum. You would think that the value of nSum should be 0. This time you see the expected average value of 2.
Adding output statements is simple enough, and the programs rebuild quickly so the cycle time is short enough. Further, in order to change an output statement, the programmer must rebuild the entire program. For a large program, this rebuild time can be significant. I have worked on programs that took most of the night to rebuild. A pointer written to the display in hex means nothing, and as soon as you attempt to dereference the pointer, the program blows. A second, more sophisticated technique is based on a separate utility known as a debugger.
However, this approach involves learning to use a debugger. The programmer controls the debugger through commands by means of the same interface as the editor. You can access these commands in menu items or by using hot keys. She can execute one step at a time in the program, she can stop the program at any point, and she can examine the value of variables. Fortunately, most debuggers offer the same basic commands. Table lists the command hot keys you use in both environments.
Running a test program The best way to learn how to fix a program using the debugger is to go through the steps to fix a buggy program.
The following program has several problems that need to be discovered and fixed. Execute the program. Single-stepping through a program The best first step when tracking down a program problem is to execute the program in debugger mode. Sometimes, the debugger can give you more information about the problem. Click OK to acknowledge the error and then the Program Reset from the Debug menu or the Stop Execution command from the Debug toolbar to make sure that everything within the debugger is reset back to the beginning.
To see exactly where the problem occurs, execute just a part of the program. The debugger lets you do this through what is known as a breakpoint. The debugger stops the program if execution ever passes through a breakpoint. The debugger then gives control back to the programmer. Now set a breakpoint at the first executable statement by clicking in the trough just to the left of the reference to cout immediately after main or pressing F5 as shown in Table A small red circle with a check appears.
The display now appears like the one shown in Figure Now execute the program under the debugger again, either by selecting the Debug item under the Debug menu, by clicking the blue check mark on the debug toolbar, or by pressing F8. Program execution starts like normal but immediately stops on the first line.
The line containing the breakpoint turns from red to blue, indicating that execution has halted at that point. Figure A breakpoint shows up as a small red circle with a check. The blue marking moves to the next executable statement, skipping over both declarations. A declaration is not a command and is not executed. You can switch to the Console window to see that the single output statement has executed, as shown in Figure Figure You can click the Console window at any time to see any program output.
So far, so good. When you select Next Step one more time, however, the program crashes ignominiously just as before. You now know that the problem is encountered somewhere within the StringEmUp function. When the program crashes within a function, either the function contains a bug, or the arguments passed to the function are incorrect. The Next Step command treats a function call like a single command. This is known as stepping over the function.
I need a different type of single step command, one that steps into the function. This time, you want to save a little time executing right up to function call before stopping. The dot disappears. Next click in the trough across from the call to the function to set a new breakpoint, as shown in Figure You can have as many breakpoints active in a program at one time as you like.
There is no reasonable limit. Now start the program over again. This time, execution stops on the function call. Step into the function. The display appears like the one shown in Figure Figure Stepping into a function moves control to the first executable statement within the function. This is the function of Add Watch. A watch displays the value of a variable each time execution is halted. The easiest way to set a watch is to select the variable on the display and press F4.
Figure shows a watch set on all four arguments to the function. Figure Setting a watch allows the programmer to monitor the value of a variable. Something seems to be amiss. The answer actually lies in the final argument. The length of the two strings is not 16 characters but 17! The main program has failed to allocate room for the terminating null.
The program terminates as soon as you execute the first statement within stringEmUp , the call to strcpy. The length of a string always includes the terminating null.
Now you update the program. What is it about being object-oriented that makes it so desired around the world? To explain, let me tell you a little story. To use my microwave, I open the door, throw the stuff in, and punch a few buttons. After a few minutes, the nachos are done. The microwave has an interface — the front panel with all the buttons and the little time display — that lets me do everything I need.
These are not profound observations. You can deal with only so much stress in your life. To reduce the number of things that you deal with, you work at a certain level of detail. In object-oriented OO computerese, the level of detail at which you are working is called the level of abstraction. Preparing functional nachos Suppose that I were to ask my son to write an algorithm for how Dad makes nachos.
They tend to worry about flow charts with their myriad functional paths. There are no objects, no abstractions behind which to hide inherent complexity. Then I would begin the task of modeling these objects in software, without regard to the details of how they will be used in the final program. Rather, they set about the problem of designing and building a useful microwave. After the objects I need have been successfully coded and tested, I can ratchet up to the next level of abstraction.
I can start thinking at the nacho-making level, rather than the microwave-making level. Classifying Microwave Ovens Critical to the concept of abstraction is that of classification. In addition, my son sees microwave ovens as just a special type of oven, which itself is just a special type of kitchen appliance. In object-oriented computerese, my microwave is an instance of the class microwave. C in Depth briefly examines the history of C and the.
NET framework and reviews a few often-misunderstood C 1 concepts that are Computational Finance Using C and C. The inclusion of both these languages enables readers to match their use of the book to their firm's internal software and code requirements.
Levy also provides derivatives pricing information for: - equity derivates: vanilla options, quantos, generic equity basket options- interest rate derivatives: FRAs, swaps, quantos - foreign exchange derivatives: FX forwards, FX options- credit derivatives: credit default swaps, defaultable bonds, total return swaps.
Available for purchase on the multi-tier website are e versi This book is for busy programmers who want a succinct and yet readable guide to C 3. Despite its conciseness, this book doesn't skimp on depth or detail, and embraces the conceptual challenges in learning C 3. The goal of Multix was to give all houses inexpensive computer access to graphics, e-mail, stock data, pornography just kidding , whatever.
Of course, this was a completely crazy idea at the time, and the entire concept failed. A small team of engineers working for Bell Labs decided to save some portion of Multix in a very small, lightweight operating system that they dubbed Unix Un-ix, the single task version of Mult-ix, get it?
The standard development tricks of the day were all machine-dependent — they would have to rewrite the same program for each of the available machines. Instead, these engineers invented a small, powerful language named C. C caught on like wildfire. Eventually, however, new programming techniques most notably object-oriented programming left the C programming language behind. Not to be outdone, the engineering community added equivalent new features to the C language.
CPP just as a Microsoft Word file ends in. The concept extension. CPP is just a convention. The resulting machine-executable files carry the extension. Keep going. How do I program?
To write a program, you need two specialized computer programs. One an editor is what you use to write your code as you build your. CPP source file. The other a compiler converts your source file into a machine-executable. EXE file that carries out your real-world commands open spreadsheet, make rude noise, deflect incoming asteroid, whatever.
Nowadays, tool developers generally combine compiler and editor into a single package — a development environment. We use one of them in this book — the Dev-CPP environment. You can download quite a range of public-domain programs from the Internet.
See the Web site for details. You can check out my Web site at www. They are two separate things and for the sake of sanity should remain so in your mind. NET which are essentially the same thing. NET are different and often just as difficult to decipher , but the territory will seem mysteriously familiar.
Navigate to and double-click the file devcpp Note that 4. Starting an installation with a threat is an inauspicious way to begin a relationship, but everything gets better from here. NET, for example. It is possible, but difficult, to undo this association. NET installed. NET coexist peacefully on the same machine, but what Visual Studio has done, let no man cast assunder. You can still open your. Personally, I prefer to use this option, even with Visual Studio.
Click the Next button. Make sure you have enough room for the program, wherever you decide to put it. Click Install. At first, nothing seems to happen. Figure displays the eventual result.
Choose whether you want to install for all users, and then click the Close button to complete installation of the package. But you knew that. Read on. You can change these settings at any time, but now is as good as any.
Choose the Settings tab. Choose Code Generation from the menu on the left. Make sure that the Enable Exception Handling is enabled, as shown in Figure Choose Linker and make sure the Generate Debugging Information option is enabled.
Figure shows you what to look for. Figure The Generate Debugging Information option must be enabled. Choose OK. Installation is now complete! Your options are saved automatically. This is a lot of clicking. My personal preference is to create a shortcut on the desktop. To create a shortcut, double-click My Computer.
Now double-click the Local Disk C:. Finally, double-click Dev-CPP — whew! Right-click the file devcpp. Drag the Shortcut to devcpp. Enter the following program exactly as written. You can cheat and copy the Conversion. Figure Bad little programs generate error messages in the Compiler window. The answer is simple but profound.
Finding an error buried in a program that builds without complaining is difficult and timeconsuming. Guess which one I vote for? There was once a language that tried to fix simple mistakes like this for you.
From my personal experience, I can tell you it was a waste of time — because except for very simple cases the compiler was almost always wrong. At least it warned me of the problem so I could fix it myself. EXE program file and give it input to see how well it works.
I have no idea how they selected function keys. A window opens immediately, requesting a temperature in Celsius. Enter a known temperature, such as degrees. After you press Enter, the program returns with the equivalent temperature of degrees Fahrenheit as follows: Enter the temperature in Celsius Fahrenheit value is Press any key to continue. Windows programs show the user a very visually oriented output, all nicely arranged in onscreen windows.
Click a topic of interest to display help. You really need to get behind the wheel itself. Programs are a bit like cars as well. All cars are basically the same with small differences and additions — OK, French cars are a lot different than other cars, but the point is still valid.
Cars follow the same basic pattern — steering wheel in front of you, seat below you, roof above you and stuff like that. This pattern is already present in this very first program. We can review the Conversion program by looking for the elements that are common to all programs. I have copied this code into a file called Template. Clarifying source code with comments The first few lines in Conversion. These first six lines are known as comments.
The compiler ignores comments. You can put any character you want in a comment. Some printers still default to 80 characters across when printing text. A newline was known as a carriage return back in the days of typewriters — when the act of entering characters into a machine was called typing and not keyboarding. A newline is the character that terminates a command line.
Later in this book, I describe the one case in which this type of comment is applied. In fact, the programmer herself may forget what her program meant if she looks at it months after writing the original code and has left no clue.
A statement is a single set of commands. All statements other than comments end with a semicolon. Why nobody asked me about that remains a mystery. As you look through the program, you can see that spaces, tabs, and newlines appear throughout the program. You may add white space anywhere you like in your program to enhance readability — except in the middle of a word: See wha t I mean?
The variable fullspeed and the variable FullSpeed have nothing to do with each other. Writing declarations The line int nCelsius; is a declaration statement. A variable contains a value, such as a number or a character.
In this case, the value of x is 10, but we could have just as well set the value of x to 20 or 30 or —1. The variable defined on Line 11 is called celsius and declared to hold an integer. A variable must begin with the letters A through Z or a through z.
0コメント