An algorithm is just the steps your program goes through, to do it's work. If your algorithm is wrong, no matter how well the rest of your program's output or performance might be, the program will not complete it's work, accurately.
Originally Posted by Ravens'sWrath
Think of the steps you go through to go to work or school in the morning: wake up, clean up, get dressed, grab a bit of breakfast, get in your car and drive to work. Each is a step that would contain several steps of it's own. Some could be left out, like breakfast, but waking up is an essential step in the algorithm. Not only do you have to wake up, but you have to wake up *first*, before you can get anything else done.
"The value passed to a function or subroutine. Its type must match that of the corresponding parameter in the declaration."
Well this one has me stumped. According to that this is a argument:
I don't think of an argument as modifying a function. I think of it as a little house warming gift, you're delivering to the function. The function must know how to respond to that gift, and since the eyesight ain't what it used to be, you tell it what kind of a housewarming gift it is that you've brought today. Flowers get dunked in a vase of water - but a CD would not!
where the variable is the argument, so by that am I right in assuming that anything that modifies a function is a argument also is there thing else besides the above that is considered an argument and can an argument have any other forms?
Remember that C didn't just arise out of thin air. It was based on 'B', but included other idea's as well. The idea of "auto" was found overwhelmingly useful and popular, and made the default. I believe this was done in the early prototype of the language.
Don't use auto?
This one in a weird way makes me unhappy, there is a keyword that there is no point in using (according to my 3 books and several tutorials). From what I have learned the auto keyword is used as a to declare a variables type, when used it would create a "local variable that loses its value as it goes out of scope" or in my words a plain old local variable.
OK so i have a few questions about this one, is there a way that I can make use of this keyword, if the answer is no... Why would someone create something unusable (I'm assuming it may have been used in earlier versions of C?)
And my last question is on this is about Automatic variables / local variables, when these variables lose they're value apron leaving the function that they are declared, are they really lost or just lost to the rest of the program, for example, if i was to use goto or some do something to make a loop that would reenter the function would the variables value contain what it did when I was there last or be given the initialized value. Maybe I should give a code example...Or at least pseudo code
The result would vary from compiler to compiler, and OS to OS, but it would not be something you could rely on. When they talk about "undefined behavior", that's pretty much a euphemism for "you're totally goofed!"
int variable = 0;
The values differ in size, perhaps, but shouldn't differ in value when you declare a variable to be some value. Int i = 0, is still going to get i equal to zero, regardless.
32 bit vs 64 bit:
I've heard some talk about this in regarding to programming, it seems that depending on your computers "architecture" the values when declaring variables may differ depending on what type of computer you are using. My questions regarding this issue are: How do I tell what type of "architecture" (I don't really know what that means...) does my computer use (=, i wonder if i should already know that, lol.
Actually, it's used a great deal, especially by game programmers. It's not stressed in the learning phase too much, because the more formal if () code is more closely aligned with how people think.
Are they're any other differences that would make porting programs difficult (differences in regarding this question, not about the lack of some libraries and other issues, I'll ask about that in a bit (=.
<expression1> ? <expression2> : <expression3> ?
well my question on this is why doesn't anyone use this (from what I've looked at it I've never seen any one use it) it looks like a good way to control the programs flow.
BTW just because I like it doesn't mean I can use it...
Please tell me why the following program doesn't work )=
variable ? printf("false\n") : printf("true\n");
(Note: I don't use this much, and it's not tested).
printf("%n tire%c", ((n < 2) ? c = ' ' : c = 's'));
Pointers are critical in getting maximum efficiency out of the computer's hardware. If you have trouble with them, just use them a little bit, and gradually, you'll get used to them. The larger and more complex your program, the more you need pointers.
Arrays and pointers?
OK i've decided these things are the reincarnation of the devil! These things are why I decided to make this list of questions...
OK what I don't understand about them is:
Pointers, why would you need / care about where something is located. I make a variable the computer makes room for the variable, I give it a value and the computer remembers it... So why after all that do we care where exactly at where it is located.
And how do you use pointers )= I think I can make a 1 dimensional array fine. but pointers they are a mystery )= Of course so are 2 dimensional arrays.
One more question on this it seems that with each dimension an array is given the more memory they require, at what point (how many dimensions) would be to much?
Static variables address a critical shortcoming of having just local variables. It's great when you can "encapsulate" the variable to within just the function that needs it. That way there's no chance of another function messing with it.
So theres global variables (entire program can use) local (Used within the function) external (from outside the program) and static (only within the program, can't be used outside it). I hope I got those right, my question in regards to these (I get local and global) is why would you need to declare static wouldn't it be better to just make sure your variables from other files (you intend to use / merge with this one) have separate variable names, would that solve the problems you may have?
Returns can show you that the program made it through execution of any function, properly, usually by returning zero. Also, the returned number may be part of a critical calculation:
I understand why main() should have a return, but what about all other functions.
answer = 3.14159265358979 * radius_sqrd().
They're in their own subdirectories. Your compiler's doc's should tell you where the default location is. (Obviously the compiler/linker knows where they are, after all. :) )
Why can't I find them )= I would like to take a look at them but don't know where to do so...
When headers are added to files, are they completely added if you wanted to use printf() by adding <stdio.h> would you add the entire thing or only what deals with print()?
If I would like to make my own printf() is it possible by using only the 32 c keywords? *very important. I must know (= *
Yes, printf is written in C, but it's not a simple function.
Hexadecimal is helpful since the computers hardware groups bytes (with 8 bits), into words, which make up things like char's, integers, floats, etc. Hexadecimal is handy for memory locations and masking, and all kinds of things like that. It's compatible with the computer's hardware, and pretty easy for humans, as well.
My only question is why use them? They seem to only confuse things, I mean you can't read them as easy as you can with regular numbers or can you? OK... so why use them (=
Windows was originally coded in C, so the answer is definitely yes. C is also very much a commercial program, however, and stays independent of just PC's or just certain types of display monitors. I believe it tries a little too hard, but understand why it's done.
C != graphics?
So it seems that all c can do is simple printing to the terminal screen )= Is there any way to make a window or anything nice looking (=
If I ever did want to add graphics to my programs would I have to learn c++
On this note what is C not good for, what would you never make a program in with c?
The L value has to be a variable that can receive a value. Constant variables would be an example of something that could not be an L variable.
lvalue and rvalue?
My compiler laughs at me and says I have an error with the above words...
So my first question is whats the command to force my computer to throw itself out a window... (=
These only deal with improperly using variables, putting values on wrong side etc. right?
Same thing - house warming gifts for the function.
Parameter = Argument?
What is the main difference between the two?
Some problems are very eloquently solved by doing a little part of it, and then having the whole function call itself, taking the new value it's found, as a parameter, and then using that number to get even closer on the next recursive call, etc. Read the Wiki encyclopedia entry on Quicksort for a good example of recursion.
So I can make a function call itself? That sounds very "interesting" so how would I do that and what would my intention be if I did?
It's important to remember that ALL recursive functions can be replaced by a regular (iterative), loop construction, but the beauty of recursion, is that it's easy to program, small, and elegant.
That should give you a start! :)
I appreciate any help/insight into the above questions.
Thanks in advance for any help that you can give
BTW my first checking of this I got 70 mispellings (= I tried to get rid of them to make it easier to understand my questions forgive me if I missed some )=