Casio Z1 Gr User Manual
Here you can view all the pages of manual Casio Z1 Gr User Manual. The Casio manuals for Personal Computer are available online for free. You can easily download all the documents as PDF.
Page 81
81 Editing a C program Once in the editor, there are two modes for editing: the INSERT mode and the OVERWRITE mode. Switch between these two modes by pressing the INS key. The INSERT mode is automatically specified when you enter the editor. The insert mode is indicated by a cursor thet looks like “_”. While the computer is in the INSERT mode, any characters that you enter from the keyboard are inserted between any characters already on the display. You can specify the OVERWRITE mode by pressing the...
Page 82
82 }↵ < 3> Note that the line number displayed at the lower right is the one requested. Now, let’s execute our program. 6.1 C Program Execution 6.1.1 To execute a program You can exit the editor by pressing the SUB MENU key, which will go back to the C mode menu. Shift SUB MENU < C > F 0 * 2 3 4 5 6 7 8 9 51113B F1>Run/Load/Source Note that the program area 1 you just used for the short program is now shown as occupied with a “*”. You need to load the program into the...
Page 83
83 To illustrate operation of the TRACE mode, we will add a sub() procedure at the top of our HELLO program, and call it in the main(). Here is how the modified program will look like: sub(){ printf(“WORLD¥n”); } main(){ printf(“HELLO¥n”); sub(); } Loading and running this program will generate following output: HELLO WORLD >_ With the TRACE function, it is possible to follow step by step the execution: .T R O N . . >tron >_ .R U N . . >run (F1-5) printf(“HELLO¥n”); Break?_ The...
Page 84
84 To interrupt execution of the TRACE mode Lets run again the program in TRACE mode: .R U N . . >run (F1-5) printf(“HELLO¥n”); Break?_ 1. You can press T or . . to execute the line and carry on the TRACE mode. 2. You can press BRK to exit the program, but stay in TRACE mode. This is useful if you want to re-run the program because you missed something. To exit the TRACE mode There are four different methods that you can use to exit the TRACE mode. 1. Enter the TROFF command and press . .....
Page 85
85 Enter the following program: .M A I N ( ) Shift { . . SPC .P R I N T F ( “ CAPS H CAPS O W SPC A R E SPC .Y. .O. .U. Shift .?. Shift ¥ N ” .). .;. . . SPC .P R I N T F ( “ CAPS F CAPS I N E , T H A N. .K. SPC .Y. .O. .U. Shift ¥ N ” .). .;. . . Shift } . . printf(“How are you?¥n”);↵ printf(“Fine,thank you¥n”);↵ }↵ < 4> The following shows how the program is stored in the source...
Page 86
86 Making your program easy to read You have probably noticed by now that we have been writing and editing our C programs in a certain format. The previous program was written and entered as: main(){ printf(“How are you?¥n”); printf(“Fine,thank you¥n”); } We could have just as easily written and input it as: main(){ printf(“How are you?¥nFine,thank you¥n”); } Or even: main(){printf(“How are you?¥nFine,thank you¥n”);} The computer would execute the program identically in either case. The first...
Page 87
87 Note that there is a direct relationship with • the 1st % construction and the 2nd argument • the 2nd % construction and the 3rd argument • the 3rd % construction and the 4th argument. printf(“D=%d H=%x F=%f¥n”65,65,65.0); You just have to be careful to ensure that the proper % construction is matched with the proper value, or else you will get strange results. Here is a list of some other % constructions in addition to those noted above. % construction Output %d %x %f %s %c decimal integer...
Page 88
88 The following results would be displayed: .R U N . . >run D=65 O=101 H=41 C=A >_ 6.2.2 Variable types and operations Declaring variable types With C programs, you have to declare the type of data that will be assigned to each variable before you can use the variable. The following statement, for example, tells the computer that the variable “x” will be used for the storage of integers: int x; The following table shows the other declarations that can be made for variables. Declaration...
Page 89
89 } The first four operations are addition, subtraction, multiplication and division. The value for “e” will be the modulus (remainder) of 49 divided by 12. When you execute the program, the display should appear as follows: .R U N . . >run 61 37 588 4 1 >_ The following statement in the first line of the program declares that all five variables will be for the storage of 16-bit integers. Short a,b,c,d,e; As you can see, you can use a single declaration for multiple variables by...
Page 90
90 6.2.3 Entering characters and values Entering a single character from the keyboard Here we will create a program that outputs a character and its corresponding character code in hexadecimal format. If you press the key for the letter “B”, for example, the format will be: Char=B Hex=0x42 The standard function getchar() is used to tell the computer to get one character input from the keyboard. In most ANSI C compilers, this function is part of the standard input / output library which complements...
All Casio manuals