Thread: What code could i use?

  1. #1
    Registered User
    Join Date
    Sep 2010
    Location
    Philippines
    Posts
    1

    What code could i use?

    Help me guys!

    I cannot think what code can I use to compare 2 numbers? im just a freshman at Programming in Turbo C....

    can someone help me?

    output:

    Enter value in Array number[0]: 12
    12 is higher than 10

  2. #2
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    If you haven't, then you will need a condition testing branch.

    Code:
    if( condition ){
    //... Do something
    }
    else{
    //... Do something else
    }e
    the condition could be: "x > y"

    Have you got any code?

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    First off, I suggest you dump Turbo C: SourceForge.net: Turbo C - cpwiki
    Now. Do you know condition and conditional operators such as less than (<) and greater than (>)?
    If you do, then can you formulate logically how you would do if you were given this problem in real life?
    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.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by ChasyLe View Post
    Help me guys!

    I cannot think what code can I use to compare 2 numbers? im just a freshman at Programming in Turbo C....

    can someone help me?

    output:

    Enter value in Array number[0]: 12
    12 is higher than 10
    Elysa is right... lose Turbo C and head for one based on standards...
    I use Pelles C and really like it, but we all have our favorites...

    smorgasbordet - Pelles C

    You should also look for texts and tutorials on C (and there are tons of them) but in specific those based on C-99.

    Finally... for the most basic stuff like comparisons and math, spend some time trying to figure it out on your own... Read the books, study the help files, etc. Asking a question online should be a last resort... Easy answers to not bring good education, my friend.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Nothing wrong with asking for help on a forum. It certainly doesn't have to be the last resort.
    As long as you are willing to put some effort into solving the question and showing that you have at least some understanding of what you do, then it's fine.
    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
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Elysia View Post
    Nothing wrong with asking for help on a forum. It certainly doesn't have to be the last resort.
    As long as you are willing to put some effort into solving the question and showing that you have at least some understanding of what you do, then it's fine.
    Elysia.. I didn't say there was anything wrong with it, but asking such basic questions does not help one devlop troublshooting skills. To really know what you're doing you still have to be able to solve the problems when help is nowhere to be found.

    I'm a bit of an old fart (60 and retired) and way back when I was learning electronics my teacher gave me a dead television set: "This is your final exam"... we went through the course, learned about resistors, capacitors, transistors, tubes (yeah I'm old enough for that) and such... Then he put us each in separate service cubicles and our final exam was to fix that broken television set without any help from anyone else ... I learned more fixing that thing than I did in the entire rest of the course.

    My point is that (in my opinion) having all this information and help so readily available isn't helping people understand the fullness of their craft...

    My first programming project was done with just me, a tutorial, the help files and my computer... I probably learned more sorting out my own mistakes than I will ever learn by asking questions.

    Indeed there is a time to come to a place like this for help... but it isn't when you get one or two errors and are too lazy to sort them out on your own.

    BTW... my favorite Pelles C compiler message: "More than 100 errors, please improve yourself!"

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It also causes 95% of all people who takes a course to fail. Not a very good idea, is it?
    In fact, you can learn a lot by asking questions to people and then thinking on them.
    You can become an expert in a language by asking questions. Far faster than empirical tests and googling. Troubleshooting is a good thing to learn, true, but you shouldn't have to overdo it. All people cannot do it the hard way.
    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.

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Elysia View Post
    It also causes 95% of all people who takes a course to fail. Not a very good idea, is it?
    It's funny you should mention that... In that same course I was telling you about we actually tasked the teacher about that very point. His answer: "If you can't pass the test, we don't want you working here." Fair enough... I was with them for nearly 10 years.

    In fact, you can learn a lot by asking questions to people and then thinking on them.
    You can become an expert in a language by asking questions. Far faster than empirical tests and googling. Troubleshooting is a good thing to learn, true, but you shouldn't have to overdo it. All people cannot do it the hard way.
    Well in fairness our entire job was troubleshooting... we fixed stuff, that was all we did.

    But I do take your point with limitations Elysia... Asking questions is one of many good ways to learn... especially when you don't like the answers you get.

    Back when I started my career there was no internet and Google wasn't even a glimmer in anyone's eye. We did what we did from 6" thick books and plain old skill. Today we have a lot more information available to us and a lot of easy help on hand... but, surprisingly, today's technicians are far less skilled than generations before them. Miniaturization makes part level repair all but impossible and now I constantly see techs who don't know how to do even the most basic parts replacements and don't have the troubleshooting skills to know which part to replace even if they could --even on equipment designed to be repairable. Heck, half of them don't even know how to solder.

    In some part it is because it's possible to get the answers to your homework online instead of from your own intellect, these guys never have to do the actual work to learn and they are getting dumber and dumber all the time.

    Now, I don't know how far this translates into programming skill but in the electronic world this is one scarey situation... A common concern amogst us old timers is that like in the middle ages, skill and knowledge are slowly reverting to the hands of the few --and an increasing number of that "few" are computers, not people-- and the day may come when we can't fix the very things we need in our day to day lives... Think what happens if the internet goes down and nobody can fix it... How screwed are these guys? How about the electricity grid, water, phone, etc. (StarTrek TOS "Spock's Brain" comes to mind)

    I've met a few truly brilliant programmers on these forums, so I will allow that I may be all wet here... but still the concern for the general "dumbing down" and lack of true skills is very real, at least in my primary skillset.

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    @CommonTater: Thank you for you comments; I never thought about the internet/forums being why the people in my EET classes seem so ignorant of what I think are the fundamentals of Electronics. I have no idea how they will ever learn troubleshooting seems to be hardly touched on at this college.

    Tim S.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by CommonTater View Post
    It's funny you should mention that... In that same course I was telling you about we actually tasked the teacher about that very point. His answer: "If you can't pass the test, we don't want you working here." Fair enough... I was with them for nearly 10 years.
    And a fair point he made. But the point I was trying to make is that a school is supposed to help you reach that goal, not just serve as some institution that weeds out the bad.


    Back when I started my career there was no internet and Google wasn't even a glimmer in anyone's eye. We did what we did from 6" thick books and plain old skill. Today we have a lot more information available to us and a lot of easy help on hand... but, surprisingly, today's technicians are far less skilled than generations before them. Miniaturization makes part level repair all but impossible and now I constantly see techs who don't know how to do even the most basic parts replacements and don't have the troubleshooting skills to know which part to replace even if they could --even on equipment designed to be repairable. Heck, half of them don't even know how to solder.

    In some part it is because it's possible to get the answers to your homework online instead of from your own intellect, these guys never have to do the actual work to learn and they are getting dumber and dumber all the time.
    The problem here is several-fold. First off, with the invention of technology, it becomes far easier to cheat. It's sad, but true.
    Secondly, today's world is moving all more towards being more complex.
    Back then, things like these were a niche, and they could get away with few people actually graduating because demand would be low. But today is another story. When we create a lot of electronic stuff, we need lots of engineers. So that puts a strain on the schools to actually graduate a lot of students.
    Also, with more complexity comes more different areas, and we cannot be experts in all fields of expertise.
    And finally, today we have more tools available. Way back, you had to memorize tables of things for math, for example. Or learn how to draw graphs. These things are not as important today; nor is soldering. Today we rely more on tools to do the job.

    I've met a few truly brilliant programmers on these forums, so I will allow that I may be all wet here... but still the concern for the general "dumbing down" and lack of true skills is very real, at least in my primary skillset.
    You are not alone in this. The fact that a lot of people graduate with a lack of understanding is a problem. Schools also not actually updating their equipment (like using compilers from the DOS age) is also becoming more and more of a problem.
    Sad to say, it's true. We can only hope for a better future.
    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
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by stahta01 View Post
    @CommonTater: Thank you for you comments; I never thought about the internet/forums being why the people in my EET classes seem so ignorant of what I think are the fundamentals of Electronics. I have no idea how they will ever learn troubleshooting seems to be hardly touched on at this college.

    Tim S.
    No surprises there Statha... In fact, these days almost all electronic service is swapping out plug in modules (eg. PCI Cards) and since functions are known on a modular level there's no need to know how they actually work. So it is that deeper knowledge is atrophying to the point where only the few involved in design actually know how any of this stuff works. And, with the passage of time and the increased reliance on computer design, even the design engineers are less and less motivated to learn... or invent.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Elysia View Post
    And a fair point he made. But the point I was trying to make is that a school is supposed to help you reach that goal, not just serve as some institution that weeds out the bad.
    Actually, the true purpose of school is to teach you how to learn. If you think about the depth of education you get on any particular topic (even engineering and medicine!) it becomes very important to realize that most people graduate these courses with exactly the right amount of knowledge to be flat out dangerous. The real learning experience begins after school, when problem solving becomes self-directed and new information is not handed to you daily.


    And finally, today we have more tools available. Way back, you had to memorize tables of things for math, for example. Or learn how to draw graphs. These things are not as important today; nor is soldering. Today we rely more on tools to do the job.
    You have an interesting definition of "tools"... a soldering iron has been my primary tool for more than 35 years. What we have today is smarter ways of accessing information that's been available to us all along... Tables and charts were printed, graphing was often done "au noggin" (in one's head) as was a lot of math that today's crew wouldn't know how to do with out computer programs.

    An example: Look up the formula for resolving the resonant frequency of a parallel RL circuit... the code is impressive... but we used to do it au noggin.

    You are not alone in this. The fact that a lot of people graduate with a lack of understanding is a problem.
    Sadly... I think it is one of our own creation.

    Schools also not actually updating their equipment (like using compilers from the DOS age) is also becoming more and more of a problem.
    Sad to say, it's true. We can only hope for a better future.
    I hear that!

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by CommonTater View Post
    Actually, the true purpose of school is to teach you how to learn. If you think about the depth of education you get on any particular topic (even engineering and medicine!) it becomes very important to realize that most people graduate these courses with exactly the right amount of knowledge to be flat out dangerous. The real learning experience begins after school, when problem solving becomes self-directed and new information is not handed to you daily.
    That is not the real purpose of a school. The purpose of a school is to help students learn what they need to learn. What schools usually do not learn out is practical experience and knowledge of how the market works.
    What you speak of is usually how it works, but not how it's supposed to work ideally.

    You have an interesting definition of "tools"... a soldering iron has been my primary tool for more than 35 years. What we have today is smarter ways of accessing information that's been available to us all along... Tables and charts were printed, graphing was often done "au noggin" (in one's head) as was a lot of math that today's crew wouldn't know how to do with out computer programs.

    An example: Look up the formula for resolving the resonant frequency of a parallel RL circuit... the code is impressive... but we used to do it au noggin.
    If I need soldering, there is usually a machine out there that can do it better than me! And when there are a lot of points to solder, the machine can do it way faster than me, with less resources and time, and probably do a better work, as well.
    And, as you mentioned, we have software to do a lot of math for us now.
    And that is fine, actually. So long as our tools work properly we become more productive.

    You may moan on how little today's people know about math and stuff, but the truth is that they would know far more than you in a sense that they can properly apply these tools and get work done faster and better.
    Except for the people who merely cheat their way through school, of course. Sad thing that.
    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.

  14. #14
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Quote Originally Posted by Elysia View Post
    That is not the real purpose of a school. The purpose of a school is to help students learn what they need to learn. What schools usually do not learn out is practical experience and knowledge of how the market works.
    What you speak of is usually how it works, but not how it's supposed to work ideally.

    You may moan on how little today's people know about math and stuff, but the truth is that they would know far more than you in a sense that they can properly apply these tools and get work done faster and better.
    I respectfully disagree about what you think a school is. While I certainly agree that a school must prepare a student for the real world a minimum extent (albeit a substantial minimum) I think the concept is stretched a little thin by your standards. The school pushing the boundaries of their students so that maybe it messes up their perfect scores is welcomed by me. It's not like when you are expected to meet such a challenge that you are intentionally caught unprepared. That only happens in real world. I would hope that experience instills a bit of self-motivation. "You will never be able to sit and say, 'I know everything I'll ever need to know; I'm done learning.' Learning is a life-long process." That being the case, education isn't all about what institution you can join to take instruction. In some phase of your life doing that is going to be a problem and yet you will have to know new things.

    You didn't just learn to take instruction in school: you learned how to teach yourself. Studying is teaching yourself. The only difference is somebody told you to do it, and you followed a lesson plan.

    That being said let's make this all tie in, coz this all feels like a big aside note. Maybe OP just didn't feel motivated to use resources he has. No one can say one way or the other, he only said he couldn't think. We can't fix that. We can be lenient, and I don't care if you are, but it's not fixing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM