Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (vheah):

Programming probs I have the sweetest professor but he flies through lectures like he's talking to professionals that have programming experiences. For my homework I have to "Design, write and debug a program that finds the change in length of a rectangular metal bar by declaring the following double variables and assigning the values shown: F is 4. N len is 3. m wid is 4. cm dep is 2. mm e is 6.8950e4 N/(mm)^2 (aluminum) delta_len is ? m The equation is: delta_len = F*len/(wid*dep*e). "

OpenStudy (vheah):

I don't want people to throw in answers because my professor has stressed before that "Your code is your code. Don't share it with others." I'm assuming that with the data given I need to make something out of it, the problem is i don't know how. I have so much vocabulary that I don't understand and a lot of key things that I don't know when to use or simply what its use is. So i have a few specific questions with the notes I have taken: What is the use of { and }, and when do you use them? What is and when do you use main( )? What is a library i.e iostream? What is and when do you use "\n" or "endl"? (in my notes it said it is used for skipping the next line but I'm not quite sure what that means or how that should look.) And how do you "declare a variable with data identified"?

rvc (rvc):

this is C++ right do you know C ?

OpenStudy (opcode):

The majority of programming languages are John von Neumann style. Learn one, the rest of the languages can be learned intuitively. A quick crash course: > What is the use of { and }, and when do you use them? The first on starts scope area, the second one receptively ends it. > What is and when do you use main( )? main() is usually the main entry point of most programming languages. Effectively you use it all the time. > What is a library i.e iostream? IO = I/O = Input/Output, which gives you access to objects such as std::cin, and std::cout, etc. (Assuming this is C++.) > What is and when do you use "\n" or "endl"? (in my notes it said it is used for skipping the next > line but I'm not quite sure what that means or how that should look.) Both output a new line, ```endl``` also clears the buffer. > And how do you "declare a variable with data identified"? Not quite sure that this one means, I suppose ```int thisisavariable;``` is a variable declared with no data. ```int thisisavariable = 0;``` is a variable with data.

OpenStudy (vheah):

I don't know C. I was not given that option to have prior to this class. The only thing that i need as a co-requisite for this was a math class that i already took. @rvc

OpenStudy (vheah):

@Opcode Thank you. That helped a tad bit. I have more questions though: what is std::cin and std::cout? and what does it mean when endl clears the buffer? I might be asking the dumbest questions. :/ I apologize for that. But I'm so new to these things it's quite overwhelming.

OpenStudy (opcode):

No need to apologize for asking a question. (Feel free to ask for a clarification if needed.) You maybe familiar with `using namespace std;`, often times when programming complex projects the usage of `std` is forbidden, mainly because every sometimes people's `std` namespace differs across platforms. If one is not worried about being platform agnostic, `using namespace std;` is often fine. (Unless you start using external headers with may have their own implementation of the objects of `cin` and `cout`, etc.) Another thing to note, is you cannot use both styles, if you decide to use `std::cin` you cannot have `using namespace std;`. Address your question more directly: `std::cout` and `std::cin` are global objects from header `<iostream>`. Try removing `#include <iostream>`, when you compile your program will most likely fail, because the objects will be unknown to the compiler. When referring to `buffer` in programming we consider it a block of memory, which stores I/O operations temporarily.

OpenStudy (vheah):

Thank you so much. It makes so much more sense.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!