First  Prev  1  2  3  4  5  Next  Last
Kondo's C++ class
Sensei
3193 cr points
Send Message: Send PM GB Post
26 / M
Offline
Posted 8/19/08
Attention!
I finished most of the papers due and I now have some time to spare to start on the next lesson I t should be out very soon.
Sensei
10136 cr points
Send Message: Send PM GB Post
25 / M / The Universe is a...
Offline
Posted 8/19/08

fruitschinposamurai wrote:

Attention!
I finished most of the papers due and I now have some time to spare to start on the next lesson I t should be out very soon.


Awesome lol I'll try if I can manage my class AHAHAHA!!
Sensei
3193 cr points
Send Message: Send PM GB Post
26 / M
Offline
Posted 8/20/08
Lesson 3

Today we are going to learn about mathematical operations in C++
If you are familiar with basic algebra this should make complete sense.
so lets set the value of a to be 4
and lets set the value of b to be 3
a+b
a*b
a/b
a-b
a%b
The first expression is quite simple it is merely a plus b, if you substitute the values of a and b in the answer would be 7. The second expression is a multiplied by b. The asterisk symbol is commonly used for multiplication, and the answer would be 12. The third expression is a divided by b or 4/3 (note that this is not an integer value). The fourth is self-explanatory. The fifth is pronounced a modulo b. It is the remainder left after dividing a by b. so the answer would be 1.

Like algebra in C++ variables can go through the above operations with other variables or numbers. A variable can also set its value to an expression involving two other variables.
For Example:
int a;
int b;
int c;
a = 2;
b = 4;
c = a+b;

Now c has a value of 6, because a(2) plus b(4) equals c(6).
This is very useful in C++ because it makes complicated operations much simpler
Example 2:
int a;
int b;
int c;
a = 123;
b = 456;
c = a * b;

And like algebra parentheses can be used because the order of operations is followed
so if you wrote a - (b/c) it would be considered valid in C++.

This seems like a lot to absorb so I will finish the lesson with an assignment.


Assignment

1. Write a program in C++ with four variables
2. I want the first variable to be given a value of 14
3. I want the second variable to be the first squared
4. I want the third variable to be the first cubed
5. I want the last variable to be the first to the fourth power.
6. Then use to cout command to put each of these values on a separate line



Note: Remember to use endl as follows
int a;
int b;
cout << a << endl;
cout << b << endl;
Posted 8/21/08
here's my assignment
Sensei
3193 cr points
Send Message: Send PM GB Post
26 / M
Offline
Posted 8/21/08
Good job Musashi-dono you did perfectly and i will tell you guys a trick

int a;
int b;
int c;

is the same as

int a, b, c;
Sensei
3193 cr points
Send Message: Send PM GB Post
26 / M
Offline
Posted 8/24/08
What happened to my class????
Student
10276 cr points
Send Message: Send PM GB Post
28 / M / I'd tell you... b...
Offline
Posted 8/24/08
Don't worry... it seems that all classes have a tendency to do this... I think it might help if people had an incentive
First  Prev  1  2  3  4  5  Next  Last
You must be logged in to post.