Friday, July 31, 2009

Please help me understand!?

Okay. I'm taking fundamentals of programming in college. We are studying C++.They start talking about declaring variables. From what I understand, a variable is a temporary location to store info. I also understand it needs a name, data type, and location in memory, and perhaps an assigned value. But, do you put this information into like Dev-C++ for example? And, how do you type in the location in memory? Or does that even need to be typed into Dev-C++? I'm soooo confused! Thanks for your answers. I really appreciate any help that can be offered.

Please help me understand!?
Ok to start with variables. They are like a row of mail boxes.


you label each box for employees, mary, sue and so on.





now you store information in them, mail that you are giving them. Now these boxes are temporary because of mary quits, you relable it new employee.





for example


you would declare a varible to store integers ( numbers )





int count


then you can store the count of users today ( this number changes/ variable)





To address memory addresses





The variable count is a lable for a memory location. The memory location is not in a format that you would understand to write your program, so you use a label such as a name you give the variable.





If you are taking a begining course, you most likely will never see this, but in the far chance I will mention it.





Pointers


your lable is actually a pointer to the memory address ( or link )


so when you access the variable name you are really altering the memory address that you don't see.


Pointers are very complicated that advanced folk have trouble with.





To address binary numbers


Computers are digital and they on recognize circuits in on or off states, otherwise known as ( 1 or 0 )





As far as character references like the number 9 or the letter "T" goes like this.





there is a standard ACHII ( I think) which states what every key on you keyboard, so your computer can understand that the letter you hit on your keyboard is actually what it is.





in other words the pc cannot understand what you are typing without a system.





we take for granted even as I write this that the screen knows what I am hitting on the keyboard. ( very complex behind the scenes).





To address what you can type into.





you can type into any text document, but you will need to put this text into a compiler which is what Visual C++ is.





Visual C++ is nothing more than an editor that allows you to compile when done. There is really nothing visual about.





not like Visual Basic





hope that helps.
Reply:Well I'm not a programmer, but i know a lil about web scripting so maybe i can help you with the number and character thing.





Letters are always Characters but numbers can be Characters or Numbers. For example:





Num (Binary):


9+1=10


1+9=10





Char (ASCII):


9+1=91


1+9=19
Reply:One suggestion: always try to do C/C++ programming in Linux environment. For that you need to use the compilers gcc/g++, which comes default with Linux. I hope the following coding will be useful to you.
Reply:declaring a variable sometimes is as easy as:





var ThisWord = "fudge"





A string is inside "quotes"....so if you have this:





var ThisNumber = "9" that is really saying that it's a character 9 (not a number)





var ThatNumber = 9; is equal to the number 9





The difference here is, you can't add "ThatNumber" to "ThisNumber" because their data types don't match....they would both have to be a data type of "number" to work....





That probably didn't help much....I know ASP, PHP, ColdFusion, but not C++


No comments:

Post a Comment