Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

Post a reply

Go back

Write your message and submit
:) :| :( :D :o ;) :/ :P :lol: :mad: :rolleyes: :cool: | :dizzy :eek :kiss :roflol :rolleyes :shame :down :up :touched :sleep :wave :swear :tongue :what :faint :dunno
Options

Go back

Topic review (newest first)

bkrKimo
2009-09-27 05:19:42

Interesting read, I learned c++ and didn't know the differences

LQ
2009-09-11 16:39:42

Well this is second edition.
Well if anywhere, it could possibly stand written in the dev c++ tutorial aswell, if you need to find a reliable source.

bobbym
2009-09-11 11:34:12

Hi LQ;

Thanks, I have Herbert's book also, must have missed that.

LQ
2009-09-11 07:48:54

Yeah it's interesting, for other variables then chars, pointers and integers it may mean using cache memory it says in my c/c++ programmers reference written by Herbert Schildt. However for chars pointers and integers it still only means putting them in register.

bobbym
2009-09-11 07:39:57

Hi LQ;

Okay as far as I remember except for the part about the cache. I don't know whether the CPU would ever use the L2 cache for this. Don't know how the compiler could instruct it to do so. Anyway the registers should be faster than even the cache.

LQ
2009-09-11 07:32:45

So how about this:

Definition of the modifier register in c

If a variable has the prefix register, it is put in a CPU register or the cache and preforms betters, but only if there is space enough. This may happen without the modifier, but in doubt and need, use it.

bobbym
2009-09-11 05:30:09

Hi LQ;

Not an error just an addition.

Description of the modifier register in c

If a variable has the prefix register, the variable will be quicker in the things it does.

The modifer register asks the compiler to use the built in CPU registers to hold the value. The compiler may not do so or may do it without the programmers consent. These registers because of their proximity are faster than ram. They are also limited in size and number.

LQ
2009-09-11 02:08:52

Please comment if for instance you find any errors

Description of c

c is a language for telling machines to do things.

Description of a variable in c.

A variable is a name that holds a value.
The name may only begin with either a letter or _ (underscore).
The rest of the name may also contain digits.
The name should never be longer then 6 symbols.
No more then the first 6 symbols of the name are read between 2 program files.
Within the file, the first 31 symbols of the name are read.

There are certain words that wont work as variable names.
A variable may not be any of these words:
asm     _cs     _ds     _es     _ss     cdecl
far     huge     interupt     near     pascal
auto     double     int     struct     break     else
long     switch     case     enum     register    
typedef     char     extern     return     union
const     float     short     unsigned
continue     for     signed     void     default
goto     sizeof     volatile     do     if
static     while

You can change a variables value whenever you like in a program after making it,
by wrighting the variablename followed by = and the value and ; (semicolon). It looks like this
variablename = value;

To make a variable, you have to give it certain prefixes on the same line

Description of a pointer in c

A pointer is a variable
that holds the adress of a value instead of just a value.
To make a pointer, an asterix * is put before the pointer name.

Description of an atomic data type

An atomic data type is the name of prefixes of variables or pointers
that tells them what it may contain. int for whole numbers, float for decimal numbers,
double for very big decimal numbers and char for a keyboard sign.
void for a pointer with an adress to anything.

Description of void

void is an atomic data type
that tells the pointer (and no other kind of variable)
that it may hold an adress to any kind of value.

Description of int

int is an atomic data type
that tells the variable that it may hold whole numbers

Description of float

float is an atomic data type
that tells the variable that it may hold decimal numbers

Description of double

double is an atomic data type
that tells the variable that it may hold really big decimal numbers

Description of char

char is an atomic data type
that tells the variable that it may hold a letter, number or digit.


Description of modifiers in c

Modifiers are prefixes to variables and pointers and comes before the atomic data type.
They set the rules of how the variables work beyond what value they can store.



Description of the modifier extern in c

extern is a modifier that, if you put it infront of a variable,
makes it possible to give the variable a value at that place from another place,
where you can create a variable. Just like a townportal scroll.
In the new place you write the variable and value like normal
with the prefixes but not extern. The value has to be able to be equated before it is needed.

Description of the modifier const in c

If you put const before a variable the value you give the variable cannot change.

Description of the modifier static in c

If a function that had a variable with the prefix static closed but opened later again,
it will open with the latest value it got.

Description of the modifier volatile in c

If a variable has the prefix volatile,
and the variable was given a value that sometimes changes,
the variable will change every time the value changes.
Which is not the case unless volatile is there.

Description of the modifier register in c

If a variable has the prefix register, the variable will be quicker in the things it does.

Description of the modifier signed in c

If a variable has the prefix signed, the value of the variable may be a negative value.

Description of the modifier unsigned in c

If a variable has the prefix unsigned,
the value of the variable cannot be negative, only positive.

Description of the modifier long in c
If a variable has the prefix long, the value of the variable can be longer then usual.

Description of the modifier short in c

If a variable has the prefix short, the value of the variable may not be very long.

Description of how you give a variable a value

You give a variable a value and prefixes
by wrighting the prefixes first and that it equals a value
and end with a ; (semicolon) like this:

prefix1 prefix2 variable = value;

you can give a variable a value later by wrighting:

variable = value;

The value can also be an equation that gives a value.

Description of what you may use in equations

In the equation you may use numbers, variables
and these ways of counting with them:
Parenthesis ( ), Multiplication ( * ), Division ( / ), Subtraction ( - ), Addition ( + ),
increment ( ++ ), decrement ( -- ) Comparings, Logics and a Depender

Around the parts of the operations in the equation you want evaluated first you put paranthesis.
Multiplication uses the * sign, division the / sign, subtraction the - sign, addition the + sign.
Increment uses the ++ sign that is put either before a value or after, it adds 1 to the value.
Decrement uses the -- sign that is put either before a value or after,
it subtracts one from the value
If decrement/increment is put after a value the change doesn't apply
until after the value is given to the variable unless you use paranthesis around the altering.

( 3*10 ) is an example of a multiplication value.
( 10/2 ) is an example of a division value.
( 3-2 ) is an example of a subtraction value
( 2+2 ) is an example of an addition value

There are several ways of comparing numbers, several comparings. but a comparing in the c language
can only equal 2 values; 1 for true and 0 for false.

3==2 Means 3 is equal to 2 and is false.
3 and 2 can be exchanged with variables, values, and equations mixed.

3 > 2 Means 3 is bigger then 2. It is true and has the value (equals) 1.

3 < 2 Means 3 is smaller then 2 and is false. false has the value (equals) 0.

3 != 2 means 3 is not equal to 2 and is true. true equals 1.

3 >= 3 means 3 is more then OR equal to 3 and is true (1).

3 <= 2 means 3 is less then or equal to 2 and is false (0).

Logics have certain special operators,
a such operator between 2 equations gives true (1) or false (0)
depending on whether
one side is zero and the other anything except zero,
both sides are zero
or both sides are anything except zero.
Another kind of operator is the not operator ! which placed infront of an equation
gives true for zero and false for anything but zero.

An equation is true if its value is anything but zero.


Operator            What it does

&&        If both left and right side of && are true it becomes true (1) else false ( 0 ).
||        If one or two of left side and right side is true it becomes true ( 1 ),
        else if both are false it is false ( 0 ).

The operator ! ( NOT ) placed infront of a value gives false for any number except 0 which gives true.

!3 Means false 3 which evaluates to false.
!0 Means false false wich evaluates to true.

Code in computers can be binary, ones and zeroes, it oftenly is.
The ones and zeroes in a value or equation can be compared and altered using other special operators.

The operator & between 2 values compares the 2 values from the smallest bit to the highest bit,
and all compared bits that are both 1 becomes one the rest becomes 0

The operator | between 2 values compares the 2 values the smallest bit to the highest bit
and if both bits are 0 it becomes 0, else it becomes 1.

The operator ^ between 2 values compares the 2 values the smallest bit to the highest bit
and if both are 1 or both are 0 the bit becomes 0, else it becomes 1.

The operator ~ before a value replaces the zeroes with ones and ones with zeroes in the value.

The operator >> before a value shifts the bits in the value one step right
and removes the bit that the value space began with, the smallest bit.

The operator << before a value shifts the bits in the value one step left
and removes the bit that the value space ended with, the largest bit.


There is also a depender used for giving a variable a depending value. It works like this:
when you give a variable a value, you write that the value equals question mark ( ? )
then you write an equation that equals either anything but zero or zero
and then you write a truevalue that becomes the variable value if the equation equals anything but zero
followed by a colon ( : )
and then falsevalue that becomes the variable value if the equation was zero followed by semicolon ( ; )

variable_name = ( 3-variab2 ) ? 25:90;

If (3-variab2) is anything but zero, variable_name gets the value 25,
if (3-variab2) is zero, variable_name gets the value 90.

To give a variable a value, you must end the prefix, variablename and value line with semicolon ( ; ).

for instance;

volatile int NumbOne = clocks;

where clocks change with time for instance. That is entirely your choice.

Examples of variables to make:

void *pointer = &value1;
static int ifunkv = 7;

Description of the first few lines in c.

The first few lines in c includes packs of functions to your program.
Those lines begins with a #
Under those lines and over the line that starts with main()
you make your own functions that may be used
within any bracketpair { } in your program.
The pair after main() for instance

Description of a function

A function is a figurer out of an expression.
When you make the function you make it possible for it to figure out the expression,
by making a variable equal the expression, or a pointer equall an adress of the expression.
and returning the variable or a pointer to outside the function.
As soon as the function returns a variable or pointer, it ends, so it can only return one.
The variables or pointers may have modifiers however.

Description of how to make a function in c

to make a function in c you first write the prefixes of the variable or pointer you want
the function to give back then you write the functions name which is a variable name
ending with a parenthesis pair.
Within the paranthesis you write prefix together with variablename of every variable
you later want to give a value for the function to work with
in order to equate the value you want it to give back.
After every variablename you put a , (comma). After the paranthesis pair () you write a semicolon.
All of this is called a prototype and here is an example of a such prototype;

float vrtfire(volatile double wind, volatile float fuel);

After you have made your prototype you write the prototype again with the semicolon removed and replaced
with a bracketpair { } and still over the line that starts with main()
and under the prototype.
within the brackets you write the code the function shall have when you use is later in the program.

volatile float vrtfire( volatile double wind, volatile float fuel ){ }

Description of if, a code your function could have

if is a function, written in small letters (case-sensitive).

if looks like this:

if( equation ){ }

within the bracketpair, you input code that will be preformed if the equation is any value except zero.

Description of for, a code your function could have

for is a re-preforming function, written in small letters (case-sensitive).

The for function looks like this

for( ){ }

within the paranthesis pair you make a variable with prefixes followed by a semicolon and
an equation followed by a semicolon and an increment of a variable.
Within the bracketpair there is code. if the equation in
the paranthesis is anything but zero it re-preform the code until the equation is zero.
It is called looping. All except the two semicolons is optional, but without the equation
you need the for loop to exit anyway somewhere. 
If a break(); is put in the function, it, in its turn will close when the line with break();
is preformed.

So the for function has the scetch:

for( prefix1 prefix2 variablename;equation;something++ ){ }

Description of while( ){ }
(small letters, case-sensitive)

while is a re-preforming function. within the paranthesis-pair there is an equation.
as long as the equation is anything but zero,
the function re-preform the code inside its bracketpair { }.

Board footer

Powered by FluxBB