programming_tutorial
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
programming_tutorial [2012/10/07 21:21] – [Arithmetic] javapimp | programming_tutorial [2023/08/18 18:15] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 50: | Line 50: | ||
You can call '' | You can call '' | ||
- | <code cpp example1.cpp> | + | <code cpp example2.cpp> |
#include " | #include " | ||
Line 70: | Line 70: | ||
Take a look at the following example. In this example we forgot to include the closing quotation mark on our output sentence. | Take a look at the following example. In this example we forgot to include the closing quotation mark on our output sentence. | ||
- | <code cpp example2.cpp> | + | <code cpp example3.cpp> |
#include " | #include " | ||
Line 92: | Line 92: | ||
In this next example, we misspell the '' | In this next example, we misspell the '' | ||
- | <code cpp example3.cpp> | + | <code cpp example4.cpp> |
#include " | #include " | ||
Line 115: | Line 115: | ||
Comments begin with the two characters %%//%%. Everything following those characters to the end of the line are considered a comment. | Comments begin with the two characters %%//%%. Everything following those characters to the end of the line are considered a comment. | ||
- | <code cpp example4.cpp> | + | <code cpp example5.cpp> |
#include " | #include " | ||
- | start() | + | start |
- | { | + | |
// This prints a message to the screen | // This prints a message to the screen | ||
print(" | print(" | ||
- | } | + | end |
</ | </ | ||
Line 228: | Line 227: | ||
We can also perform calculations using variables as terms to the calculation: | We can also perform calculations using variables as terms to the calculation: | ||
- | <code cpp example9.cpp> | + | <code cpp example10.cpp> |
#include " | #include " | ||
Line 257: | Line 256: | ||
A variable can also be used in a calculation that updates itself. In this case, the value in the variable is used in the calculation, | A variable can also be used in a calculation that updates itself. In this case, the value in the variable is used in the calculation, | ||
- | <code cpp example6.cpp> | + | <code cpp example11.cpp> |
#include " | #include " | ||
Line 275: | Line 274: | ||
In the next example, we'll write a program that counts from 1 to 10. Notice that this program uses only one variable '' | In the next example, we'll write a program that counts from 1 to 10. Notice that this program uses only one variable '' | ||
- | <code cpp example6.cpp> | + | <code cpp example12.cpp> |
#include " | #include " | ||
Line 306: | Line 305: | ||
12345678910 | 12345678910 | ||
</ | </ | ||
- | |||
- | ===== Practice ===== | ||
- | - Write a program that calculates how many days are in two weeks. | ||
- | - Use a variable called '' | ||
- | - Use a variable called '' | ||
- | - Use a variable called '' | ||
- | - Print the value of '' | ||
===== println ===== | ===== println ===== | ||
Line 318: | Line 310: | ||
Notice that all the numbers in the last example are up against each other. That's because we didn't print any formatting like we did before. What if we wanted to print each number on its own line? We can use a new command '' | Notice that all the numbers in the last example are up against each other. That's because we didn't print any formatting like we did before. What if we wanted to print each number on its own line? We can use a new command '' | ||
- | <code cpp example7.cpp> | + | <code cpp example13.cpp> |
#include " | #include " | ||
Line 359: | Line 351: | ||
</ | </ | ||
- | ==== Practice ==== | + | ===== Practice |
- Write a program that prints the powers of 10. | - Write a program that prints the powers of 10. | ||
- Start with a variable set to 1. | - Start with a variable set to 1. | ||
- End when the variable reaches 1,000,000. | - End when the variable reaches 1,000,000. | ||
+ | - Write a program that calculates how many days are in two weeks. | ||
+ | - Use a variable called '' | ||
+ | - Use a variable called '' | ||
+ | - Use a variable called '' | ||
+ | - Print the value of '' | ||
- | ===== Strings ===== | ||
- | <code cpp example9.cpp> | + | ====== Strings ====== |
+ | |||
+ | <code cpp example14.cpp> | ||
#include " | #include " | ||
Line 375: | Line 373: | ||
</ | </ | ||
- | ===== Getting Input ===== | + | ====== Getting Input ====== |
- | <code cpp example10.cpp> | + | <code cpp example15.cpp> |
#include " | #include " | ||
Line 390: | Line 388: | ||
</ | </ | ||
- | <code cpp example11.cpp> | + | <code cpp example16.cpp> |
#include " | #include " | ||
programming_tutorial.1349644869.txt.gz · Last modified: 2023/08/18 18:15 (external edit)