Like Tree3Likes

Noobs reading "Jumping into C++" - Practice Problems discussion

This is a discussion on Noobs reading "Jumping into C++" - Practice Problems discussion within the C++ Programming forums, part of the General Programming Boards category; I wanted to open a thread for newbies also working through "Jumping into C++" and working the practice problems. I ...

  1. #1
    Registered User Jeff Dean's Avatar
    Join Date
    Feb 2013
    Location
    Austin,TX
    Posts
    6

    Noobs reading "Jumping into C++" - Practice Problems discussion

    I wanted to open a thread for newbies also working through "Jumping into C++" and working the practice problems. I haven't found any other reference to possible solutions to these problems and want to hear how others have handled them.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,750
    The more direct approach would be to post your actual question on a new thread, and get specific help on the topic you're stuck on.

    Your post basically reads as "please send me your answers".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User Jeff Dean's Avatar
    Join Date
    Feb 2013
    Location
    Austin,TX
    Posts
    6
    Salem,

    No that was not my intention at all. I was wanting to open a thread where questions/ideas/discussion about those practice problems specifically. If I was saying "Please send me your answers", I would have posted a problem for which I needed answer

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    2,889
    I was wanting to open a thread where questions/ideas/discussion about those practice problems specifically
    So why don't you start by presenting one of the problems along with your solution. Then ask specific questions about the problem and your solution.

    Jim

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    It seems unlikely that there are others who are at the same point of going through the same material as you, and are members of the same forum.

    You may as well show us what you're working on. Besides, you'll be shown much better solutions from others on here who are well beyond the beginner stage.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User Jeff Dean's Avatar
    Join Date
    Feb 2013
    Location
    Austin,TX
    Posts
    6
    I am a complete newbie to coding. I am using Allain's book "Jumping into C++" as an introduction to C++. I have looked for a way to contact or read posts from others who are working through this book. At this point I am not stuck on a particular problem, but was hoping to hear from those who is working with this book. If this is an inappropriate use for this board, I apologize.

  7. #7
    Registered User Jeff Dean's Avatar
    Join Date
    Feb 2013
    Location
    Austin,TX
    Posts
    6
    I do have an very remedial question regarding FOR loops.

    As I understand from what I read in the book, when a FOR loop is defined, the variable that is utilized does not have to be declared prior to that loop, so the for definition actually declares and/or initializes a variable (or can use a variable that has already been declared).

    If I were to use a variable in a FOR loop that was not previously declared, is the scope of that variable limited to that loop?

    Example, just to be clear:

    Code:
    for ( int i = 0; i < 10; i++ )
    {
    cout << i << '\n';
    }
    In this example, it is possible that variable i is declared first in this for loop. If this is the case, would i only be available for the code "cout << i <<'\n\;"? (such that this variable functions only as a marker to execute a specified number of redundant tasks). I am assuming this is the case but the book did not mention a scope concern.
    Last edited by Salem; 02-26-2013 at 02:24 AM. Reason: fixed positioning of code tags

  8. #8
    Registered User
    Join Date
    May 2010
    Posts
    2,889
    If you declare a variable in the loop initialization section then yes that variable is only available inside the loop. But if you want to use that variable after the loop you can declare the variable prior to the loop:
    Code:
    int i;
    for(i = 0; i < someNum; ++i)
    { 
       do something
    }
    
    or 
    
    int i = 0;
    for(; i < someNumber; ++i)
    {
       do something.
    }
    Jim

  9. #9
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Quote Originally Posted by Jeff Dean View Post
    I am a complete newbie to coding. I am using Allain's book "Jumping into C++" as an introduction to C++. I have looked for a way to contact or read posts from others who are working through this book. At this point I am not stuck on a particular problem, but was hoping to hear from those who is working with this book. If this is an inappropriate use for this board, I apologize.
    Oh, it's not so much inappropriate, it's probably just a bit too optimistic. It's better to provide something to talk about to start the ball rolling, and let the discussions go wherever they go.
    Others in a similar situation are more likely to find this forum and thread if there is something interesting or useful within it that relates to their situation.

    In the mean time, lets discuss something specific.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,897
    Please don't put your reply in code tags.
    Put only the code in code tags.
    Salem and stahta01 like this.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User Jeff Dean's Avatar
    Join Date
    Feb 2013
    Location
    Austin,TX
    Posts
    6
    Jim, Thanks for the response. This is what I assumed, but it wasn't specified, and I didn't want to proceed on an assumption.

  12. #12
    Registered User
    Join Date
    Mar 2013
    Location
    Roswell, Georgia, United States
    Posts
    2
    I do have a question. I am just starting out with C++ as you may have guessed and in the first program (the "Hello world" program) i opened the sample, pressed F9 and of course it said, "Hello world."

    Heres the thing thats getting me...
    the program:
    Code:
    # include <iostream>
    Code:
    using namespace std;
    
    int main ()
    {
          cout << "HEY, you, I'm alive! Oh, and Hello World!\n";
    }
    Now correct me if im wrong, but shouldn't the program show "HEY, you, I'm alive! Oh, and Hello World!" as opposed to just "Hello World!"? The book tells me I should play around with the program and try to make it say different things. No matter what I type, or omit within the quotations it always says "Hello World!" when I execute it.

    Now I could be overlooking something obvious but right now I havent a clue why its doing that. Help?

    EDIT:​ Actually at this point, it doesnt matter if i start a new project or anything, for the hell of it i clicked "Run" and it did it again. I guess im not using Code::Blocks correctly i guess....

    EDIT: Managed to get it to stop the Hello World program... kind of... now when i put in the program its telling me that "<iostream>" doesnt even exist ("no such file or directory")
    Last edited by Wilave; 03-05-2013 at 01:43 AM.

  13. #13
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,652
    For the original issue, every time you make a change to the code you will need to save the change and recompile before running it in order for it to take effect.
    whiteflags likes this.

  14. #14
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    >>EDIT:​ Actually at this point, it doesnt matter if i start a new project or anything, for the hell of it i clicked "Run" and it did it again. I guess im not using >>Code::Blocks correctly i guess....

    I just tried simulating the problem and I'm not able to reproduce. The F9 on Code::Block actually recompiles and runs the compiled code. So for sure I would expect to see the changes you've made.

    One other things I noticed was that, the code::block takes the text from the current editor buffer. Meaning you dont have to save the code before you F9. In fact it saves and then recompiles the code. Whatever it is, you do to the code I think it should work. If it dosn't I strongly suggest you close and reopen the code::block and just try it a single empty file rather than creating a new project.

    ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  15. #15
    Registered User Jeff Dean's Avatar
    Join Date
    Feb 2013
    Location
    Austin,TX
    Posts
    6
    Quote Originally Posted by Wilave View Post
    ....Now I could be overlooking something obvious but right now I havent a clue why its doing that. Help?

    EDIT:​ Actually at this point, it doesnt matter if i start a new project or anything, for the hell of it i clicked "Run" and it did it again. I guess im not using Code::Blocks correctly i guess....

    EDIT: Managed to get it to stop the Hello World program... kind of... now when i put in the program its telling me that "<iostream>" doesnt even exist ("no such file or directory")

    yeah it sounds like you did not compile after changing your code. There is an icon of a gear next to the green arrow "run" icon. The code that runs each time you run is the previously compiled.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "uniqe" practice for 8 qeens problem
    By megazord in forum C Programming
    Replies: 21
    Last Post: 11-21-2009, 01:23 PM
  2. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  3. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM
  4. fopen("FILE_IN.TXT", "r") problems
    By BillD in forum C Programming
    Replies: 2
    Last Post: 05-21-2002, 04:07 PM
  5. Replies: 32
    Last Post: 03-20-2002, 01:21 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21