Thread: C++ Program logic Discussion

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    1

    C++ Program logic Discussion

    C++ program to find the GCD

    Is The logic is easy to understand here for beginners or not .
    I write c++ examples for beginners i try to keep the logic as simple as i can so every beginner can understand the logic.
    need suggestions is there any change required here.?


    C++ program to find GCD

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Suggest explaining what "%" operator is called and what it does.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Why do so many people feel they need to write tutorials these days?!..

    The code has terrible formatting and use of whitespace, and is terribly inefficient. It doesn't even mention Euclid's algorithm, which if there was one thing that you would not leave out of such a discussion, that would be it.

    Try and think about what you are trying to teach. Are you trying to teach C++, or are you trying to teach algorithms, or are you trying to teach how to examine code and work out what it does. I sure as heck hope you aren't intending to just teach how to program.
    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"

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by iMalc View Post
    Why do so many people feel they need to write tutorials these days?!..
    Because it is easier to write a few tutorials than to write a complete guide to any aspect of programming. And, superficially at least, writing tutorials can lead others to believe you are an expert in much more.

    In other words, people with a little knowledge are seeking quick kudos with little effort applied.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  5. #5
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by grumpy View Post
    Because it is easier to write a few tutorials than to write a complete guide to any aspect of programming. And, superficially at least, writing tutorials can lead others to believe you are an expert in much more.

    In other words, people with a little knowledge are seeking quick kudos with little effort applied.
    On the other hand, if guided properly, writing such a document is a good learning experience.
    For example, I wrote this A Gentle Introduction to IO Streams in C++ - Cprogramming.com for this site a few years ago.
    (Mainly because a few friends of me commented that C++ streams were 'stupid' and difficult, just because they were familiar with C I/O !)

    Having gained in a little bit of experience, I can see now, that there are a few places where it could have been better...but it was definitely a nice experience for me.

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by manasij7479 View Post
    On the other hand, if guided properly, writing such a document is a good learning experience.
    Sure. An effective way of learning something is to try and teach it. However, that is a side effect though - the primary goal of any good teach (or tutor) should be on helping others learn.

    I'm not arguing that tutorials are bad things. However, iMalc asked a question about a observable trend that more people are writing tutorials.

    I don't completely subscribe to the old saying "Those who can, do. Those who can't, teach." However, there is an element of truth to it. When lots of people taking up teaching (or writing of tutorials) one of the factors is fewer people in a position to do, so more people fall back on teaching.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  7. #7
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by grumpy View Post
    I don't completely subscribe to the old saying "Those who can, do. Those who can't, teach." However, there is an element of truth to it. When lots of people taking up teaching (or writing of tutorials) one of the factors is fewer people in a position to do, so more people fall back on teaching.
    The old saying "Those who can, do. Those who can't, teach." is actually a compliment. It means that if a person was very good at what they do (e.g. a soldier) then let them keep doing it. If they, for some reason, can no longer physically perform this role then instead of "wasting them", reassign them and let them teach. People (ab)use the saying and use it in a derogatory fashion, but it's not what it really means. I concede that the derogatory use is more prevalent but that doesn't change the original, intended, phrase.

    Edit: I can't find a source for this now. Maybe I dreamt it up in my imagination.
    Last edited by Hodor; 11-24-2013 at 07:45 PM.

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    And the variation of the saying "Those who can't teach, administrate" likely started by teachers.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  9. #9
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Hodor View Post
    The old saying "Those who can, do. Those who can't, teach." is actually a compliment.
    I've never heard it in that way. I just looked it up, and found that the expression is actually a quote from George Bernard Shaw's "Man and Superman". It was not a compliment. I don't know if that is the original source.

    Bob: I'm so discouraged. My writing teacher told me my novel is hopeless.
    Jane: Don't listen to her, Bob. Remember: those who can, do; those who can't, teach.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  10. #10
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by grumpy View Post
    I've never heard it in that way. I just looked it up, and found that the expression is actually a quote from George Bernard Shaw's "Man and Superman". It was not a compliment. I don't know if that is the original source.

    Bob: I'm so discouraged. My writing teacher told me my novel is hopeless.
    Jane: Don't listen to her, Bob. Remember: those who can, do; those who can't, teach.
    Yeah as I said (in an edit) I can't find an reliable reference, but for some reason it's in my mind. Weird stuff.

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by grumpy
    I just looked it up, and found that the expression is actually a quote from George Bernard Shaw's "Man and Superman". It was not a compliment.
    Heh, but if we look at the context, it seems to have been constructed or quoted for humour in a list of sayings that is ancillary to the play itself: Maxims for Revolutionists

    Quote Originally Posted by grumpy
    Bob: I'm so discouraged. My writing teacher told me my novel is hopeless.
    Jane: Don't listen to her, Bob. Remember: those who can, do; those who can't, teach.
    I'm not clear why you wrote this, but I note that it isn't part of the play. If you read it somewhere, it is merely an example of how we might use the saying, but you presumably already knew the common usage.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please help me with the 'Logic' of this program
    By andy8 in forum C++ Programming
    Replies: 6
    Last Post: 08-23-2011, 10:23 AM
  2. logic of the program.
    By vijayshankar in forum C Programming
    Replies: 5
    Last Post: 02-08-2011, 05:30 AM
  3. What is the logic for this program
    By Shidlingayya in forum C Programming
    Replies: 4
    Last Post: 08-27-2007, 06:03 AM
  4. Replies: 11
    Last Post: 10-24-2004, 10:28 AM
  5. logic on a program
    By officegirl in forum C Programming
    Replies: 0
    Last Post: 10-13-2001, 10:41 PM

Tags for this Thread