Thread: Sorry, lets try again(C++ Help)

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    9

    Sorry, lets try again(C++ Help)

    Code:
    http://cboard.cprogramming.com/cplusplus-programming/129798-amazing-cplusplus-hw-help.html
    Ok that was my first thread and I want to first off apologize for not putting the work I tried on my own. My mistake....sorry!
    For those who actually tried to help me, I thank you, I really appreciate it.
    You others who just wanted to make a joke of me....i cant curse on here but I didn't need any of you posting to just make me seem dumb. I admitted that i was terrible at this, but im doing it because I want to be better. Also that IF anyone wanted to do it all for me that they COULD. I DID NOT come here to ask you guys to do my work and leave...ok? I guess because it was my first post you thought it would be my last. Anyways for any of you lames that want to make themselves look cool over the internet by trying downgrade guys like me....simply F each and everyone of you. Thanks and hopefully I still be here after this. =)

    Anyways thats my little rant. What i really came here for is to show u the simple program I did. Dont laugh >,>

    Code:
    {
     int num1,num2,num3;
     int lowest;
     cout<< "What are the numbers?";
     cin>>num1>>num2>>num3;
    
     lowest=(num1,num2,num3);
    
     if(num1<num2,num3)
    	 cout<<lowest<< "is the lowest";
    	return 0;
    }
    The assignment is in the first link(my first post) The first part is basically to take three integers as parameters , find the smallest and return it.
    My problem is when i run the program it always picks the third number and im not sure what im doing wrong. But I believe my mistake happens to deal with the "if statement". I would appreciate any help....ACTUAL HELP(if you dont got anthing helpful to say, then dont say.....anything) Thanks

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    What are you attempting here
    Code:
    lowest=(num1,num2,num3);
    and here
    Code:
     if(num1<num2,num3)
    Explain your thought process.

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    9
    Ok here

    Code:
    lowest=(num1,num2,num3);
    To be honest I was looking in one of my books and thats how i got the idea. What I was thinking was that "lowest" would have to equal to one inputted numbers in that parameters. So...

    Code:
    if(num1<num2,num3)
    so when it came down to my if statement...I was thinking if that "number 1"(num1) is less then num2 and num3. Then the statement would find and display the "lowest" automatically

    But as i was writing this, i can kinda see how it makes no sense =/ kinda

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Number 1: 18.2.4: The Comma Operator

    Number 2: There is no easy way. You must compare the numbers just as you would on paper. Is num1 < num2? If so, is num1 < num3? Etc.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    There is an easy way, but that would be cheating The whole point of the exercise is to write the algorithm.
    Anyway, start by writing down the logic on some paper, then present it here. That is, basically how you would do it if you were given the problem in real life.
    Once you get the logic down, we can discuss syntax.
    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.

  6. #6
    Registered User
    Join Date
    Mar 2010
    Location
    pkr
    Posts
    32
    Decomposition has really helped me a lot.... may it be that I am currently learning the language and my programs are pretty small. I think no one should ignore that thing

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Well it seems that you didn't need a better understanding of the assignment, as we surmised, you do in fact understand what is required. What you do not understand yet is how to accomplish the task using the programming language specified.

    That's fantastic to see that you've made an attempt, and it would probably even compile when placed into a function, which is a step above many that post here. This is about all we could ask of you. By even getting this far, you're well on your way towards your goal.

    The lesson here is that even when you do not think you know where to start, always try.

    Also, you'll notice that as much as we love to help, we also very much like to ensure that we only give you as much help as you really need and let you make the leap to figuring most of it out on your own. It should give you a greater sense of accomplishment.
    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"

Popular pages Recent additions subscribe to a feed