Slashdot Mirror


Resources for Teaching C to High School Students?

mctk asks: "I'm a high school teacher who, disappointed with the lack of computer science in school, has promised to teach a few motivated students programming after school. As an enthusiastic novice with three semesters of C under my belt and a few side projects worth of experience, I feel competent yet ignorant. I would really appreciate suggestions for resources on C that are written to be accessible to high school students and contain lots of ideas for activities. Perhaps you've had success with a series of books that spans beginner to advanced? Do you have any activities you would recommend? How would you map a student's first year of coding? I welcome any and all suggestions. While we're on the subject, is there a brace style that is most standard in the industry?"

22 of 166 comments (clear)

  1. Don't teach the language by simm1701 · · Score: 4, Insightful

    Don't try to teach the language, any more than you teach someone how to use a pen when writing.

    Teach the mentality, the methodology of problem solving.

    Teach basic algorithms, data structures and coding theory - give them an understanding of where the libraries they are suing will come from.

    More importantly for modern world working teach colaberation, give them a real group project to do, each of them writing different interfaces or different parts of an interface for a whole program (something like a simple game such as tron is ideal for this)

    By doing all of this the language becomes almost incidental - which is really what you want, who knows what the demand for C, C++, javam C# will be in a few years time, but learning the right methodology and colaberative practices will stand them in good stead for years to come.

    --
    $_="Slashdotter";$syn="OTT";s;..;;;sub _{print shift||$_};s!ash!Perl !;s=$syn=ack=i;tr+LLEd+BLAH+;_"Just Another ";_
    1. Re:Don't teach the language by Bones3D_mac · · Score: 3, Informative

      I definitely agree with the parent post. Without understanding things like basic algebra or how to plan out an algorithm before even coding it, you won't get past "Hello, World" with most of them. You can't assume they'll already know this stuff or have any programming experience.

      Try a few exercises away from the computer where the students can learn without the pressure of a blinking cursor demanding some kind of input from them right off the bat. Look at things that are popular in their culture such as games and have them try to break the rules of each game down to instructional steps, as well think about the thought process that goes into planning a move, and then explain it in instructional terms... all of it in plain english.

      Another good one, is learning how to sort various forms of data, along with the numerous ways one can achieve a sort (such as the bubble sort). A great physical example of sorting are things like the Towers of Hanoi puzzle (the one with the disks and three pegs), or a deck of playing cards.

      Pushing an entire programming language on someone before they know the basics of how programs function will only scare or frustrate them... especially when they have the prospect of a failing grade looming overhead.

      Get them thinking outside the box before putting them *in* one.

      --


      8==8 Bones 8==8
    2. Re:Don't teach the language by edwdig · · Score: 2, Interesting

      If you go heavy on the pointers, you will either greatly improve their understanding of things, or completely scare them away. My girlfriend took a class once that essentially covered how to use computer programming to apply engineering concepts. The course had knowledge of C as a prereq, so she asked me to teach her. She really enjoyed programming and kept pushing to learn more until we hit pointers. At first she was ok, until she encountered her first pointer error. Once she understood what happened, she instantly realized all the potential errors and complexity that pointers introduce. At that point, she said to me "How do you deal with this all the time? I could never do that." Shortly after that, the teacher realized that no one in the class knew how to program, and changed the class so that you could do everything in Excel. That was the end of her programming. She wouldn't even consider learning something easier. This was without me ever even implying anything about pointer math. I don't think I ever got to pointers to pointers.

      Anyway, my advice is to delay introducing pointers as long as possible.

  2. Watch out, though... by Channard · · Score: 2, Insightful

    ... plagiarism is bound to be a possibility, especially with access to the internet. I know what when I was doing my C course years back at school, a lot of students ended up borrowing chunks of code from each other. And, in a few cases, taking one listing and just modifying it for their own purposes. And since they moved the code around a bit no-one really got busted. That was before we even had access to the internet, either!

    1. Re:Watch out, though... by StupidMBA · · Score: 2, Informative
      ...has promised to teach a few motivated students programming after school.

      It's an after school program. I really don't see cheating as a problem. They're kids who want to learn something: not just get their ticket punched. In a normal school class, though, I'd agree with you - up to a point.

      I could easily make a block of code look and function different without having any knowledge of how or if it works.

      ...(var++ to var=varp+1).

      They could learn a bit if they tried to replace var++ with ++var. Or, if they did this:

      var= var+1; var == var + 1;

      I think you get my point. And hopefully, I got yours ;-)

      I'm still on my first cup of coffee.

      --
      Don't mod me down: I was joking!
  3. I know I'll get modded down for this: by kestasjk · · Score: 5, Interesting

    But don't teach them C. Teach them a language that focuses on how to structure programs without bogging them down with memory management, pointers, etc, etc. A firm understanding of OO would also be much more useful and much easier to grasp.
    There's a reason there are so few resources on teaching C to high school students; it wasn't meant to be taught to high school students.

    --
    // MD_Update(&m,buf,j);
    1. Re:I know I'll get modded down for this: by AlXtreme · · Score: 3, Informative
      Remember that these are kids. More than enough time to learn the nitty-gritty malloc-details or pointer arithmetic. Programming should be fun in order to capture their attention.

      I agree with the OP, C would be a terrible choice for first-time programmers IMHO. You need to keep them motivated, and that works best when the reward-to-effort ratio is high. Python would be a great choice: learn them the basics (forced indenting! \o/), and introduce them to stuff like pygame which allow nice results with very little code. At the end of the semester they would be able to make small stand-alone games. Kids like flashy things.

      For a follow-up course, you could choose to go C/C++. But it would only be of use to those who will eventually get a CS/EE degree, which already (should) have enough courses on C.

      --
      This sig is intentionally left blank
    2. Re:I know I'll get modded down for this: by iamdrscience · · Score: 3, Insightful

      I disagree, I think Python is a spectacular first language. When you're teaching kids to program it helps to keep them away from the nitty gritty at first to keep their interest. Having to learn a lot of foreign concepts before being able to program something fun is what turns a lot of people off to programming, python gives the instant gratification but is also powerful and flexible enough to teach the concepts of programming. Once a student is in the programming mindset you can move them on to more complex/powerful languages like C/C++ and Java.

    3. Re:I know I'll get modded down for this: by Peter+La+Casse · · Score: 2, Insightful
      Both perl and python allow bad coding practices far too easily, whereas you can write very good code in them, but its better to learn the discipline first.

      This is a key point, I think. Python doesn't force you to do the things that good programmers do anyway. Then again, C, Java etc. let you get away with all sorts of bad programming practices too.

      I think it is easier to explain the concept of "type" with a language that forces you to declare your variables and their types before using them. But, that's a pretty minor advantage, and I think it's outweighed by the many practical advantages of Python.

  4. You need more... by ForestGrump · · Score: 3, Funny

    You need more of 3 things.
    1. Funding to buy letters.
    2. A better lesson plan so you can aim for something higher than a class of C students.
    3. A tech savvy room of students.

    1. For a class of 30, I would suggest 10 As, 20 Bs, 10 Cs, 5 Ds and 2 Fs. Yes, it doesn't add up to 30, but you should give mostly As and Bs, a couple Cs for those seniors who just want something, anything to take and pass while they transition from HS to college, and the D/Fs are for those who are truly slackers and just don't even give you the half effort.

    2. Sorry, I hate to shoot down others, but you seriously want a class of C students? I'm sure administration wouldn't be too happy with that.

    3. I hate to lay it to you, but I've seen average college students have a hard time dealing with scripting, and teaching programming is thinking differently to a higher level. You said you want to teach a few motivated students, yet you need to be open to everyone who enrolls. I would suggest you have lower and upper level classes. Lower level will teach the basics of how a computer thinks, and how to write a basic program. Those in the upper level, is more independent study and you're there as their troubleshooter, adviser, and teacher for when they need new concepts and get stuck. And while you're at it, make writing a short paper (maybe 300-1000 words) on the project they did. It's good for them to learn documentation, communication and know you're boss.

    Ok, 1 and 2 were a joke, but 3 was serious. If anyone is upset, laugh. it's meant to enlighten your day. god its 3am, and i have a final in 5 hours and i'm only 50% prepared.

    Grump.

    --
    Is it true that more people vote for the winner of American Idol, than vote for the president? -Ali G.
  5. I share your sentiment by A+beautiful+mind · · Score: 2, Funny

    For example, did you know that 99.99% of high school students can't read Perl?. Shameful, shameful.

    [foot icon here]

    --
    It takes a man to suffer ignorance and smile
    Be yourself no matter what they say
    1. Re:I share your sentiment by iamdrscience · · Score: 2, Insightful

      I'm surprised it's as high as .01%, I've never been able to read any Perl I've written.

  6. Re:Memory by Timesprout · · Score: 2, Insightful

    Actually your points are all good reasons why C should not be the language taught. These are high school kids who are going to stay back after to school to persue an interest. Getting them bogged down in the nuts and bolts of pointers and memory mangement will probably only serve to confuse then bore then alienate them.

    Personally I would favour Java as a teaching language because its basic syntax and structure is similar to most modern languages, its OO, easily debugged, requires exception handling, a JDK and an editor are all thats required and there are a plethora of libraries and frameworks available for more complex coding. Perhaps most importantly though they will be able to achieve results quite quickly rather than watch dangling pointers and memory leaks crash their code. When they have the basics of Java and they are still interested then you can show them some of whats happening under the hood.

    --
    Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
    What truth?
    There is no dupe
  7. Teaching books, not reference. by Aladrin · · Score: 2, Informative

    Some posters have actually recommended that you teach from reference books, instead of books meant to teach the language. I'm amazed and appalled.

    http://www.deitel.com/books/chtp5/

    Deitel & Deitel books are amazing. The professor I had in college used them to teach, even though the college didn't actually approve them. Even the worst of the students was able to understand the examples and follow along. I was amazed that he managed to teach the worst few the basics and they could actually write programs. Seriously, they had NO business trying to learn programming, and they were learning.

    But don't just hand them the book and tell them to have fun. Take each chapter and make a lesson from it, as if it wasn't in the book and you had made it up yourself. (Obviously, don't read from the book.) You'll automatically say it differently than the book did, and when they go back to the book, they've got a second way of looking at it automatically.

    And make them type in the code. Don't let them copy it from the CD. If sounds stupid, but it definitely helps them remember what's going on, and the mistakes they make in typing will help teach them to debug.

    --
    "If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
  8. in high school... by defy+god · · Score: 4, Interesting

    In high school, I took an AP Computer Science class that taught C++. If I understood then what I understand now, learning C++ would have been a whole lot easier. My teacher focused too much on the language instead of concepts.

    After several failed attempts at trying to learn how to program, I finally understood basic concepts such as variables, integers, arrays, etc. I then took a more basic computer science class, "Algorithm Design/Problem Solving," that used the book Programming Logic and Design. This book does not use or concentrate on any specific programming language. All our assignments were done in pseudo-code and we had to show the logic of what we wanted accomplished. I have to admit it was a lot easier trying to convey the logic without having to worry about the syntax.

    It's been a couple semesters since I've taken that class, without any programming in between, and now I've picked up The C Programming Language. I am currently half way through the book and ,I must say, I finally understand and appreciate the concepts being taught. I wouldn't quite recommend this book to the pure beginner, because it assumes knowledge about basic concepts such as variables, compiling, etc. The book, at a little less than 300 pages, is written and presented much better than the 1000+ page programming books I've run across.

    If I were back in high school, I would love to have these concepts introduced at a gradual progression. Basic programming concepts -> Logic & Design w/ pseudo-code -> the actual language of choice using an easy to learn (30 minute intro) compiler. Of course, hindsight is 20/20 and I'm not too sure if I would have paid as much attention to the first two concepts. Since you are teaching in a high school, I take it you have 2 semesters to teach the class. Perhaps dedicate the first half of the first semester with logic. You can have them play different logic games and tie that in with the lessons.

    Creating a good foundation makes learning and teaching a whole lot easier.

    --
    hackers of the world unite!
  9. A free book to learn CS using Python by bigsmoke · · Score: 5, Informative

    If you want to teach basic programming skills using Python, there's a very nice free book which can help: How to Think Like a Computer Scientist: Learning with Python

    --
    Morality is usually taught by the immoral.
  10. C IS a learning tool by Iwanowitch · · Score: 2, Interesting

    We had C during our Computer Architecture classes. The fact that it translates easily into assembly and machine code can be a benefit.
    One of the coolest things we did was to write an asm method, write a C program that uses it, compile them with -O0 and debugging info, and then link them together manually, load them in a debugger and see what exactly happens. Not something you should do in your everyday life, but a fantastic experience.
    However, I agree that it's not a language to teach day-to-day programming with, or to start learning to program. There are a lot of better languages for that.

    --
    One CS student VS 893 DOS games: Let's play oldies
  11. Educate the Educator - Resources by Dareth · · Score: 2, Informative

    You have the basic experience to continue learning, and pass on the relevant parts to your students. Some resources I would recommend are the MIT Opencourseware and the Berkeley Webcast.

    These resources provide two similar but different approaches to learning about computers and programming.

    --

    I only look human.
    My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
  12. Consider Their Maths Background by miyako · · Score: 2, Informative

    I think that teaching kids to program in C is a great idea. I started out by taking C++ in highschool, and I'm now working as a professional developer.
    I've seen a lot of comments saying that you should focus less on the language, and more on things like datastructures, algorithms, analysis, and design. I agree that it's important to give some instruction on the basic concepts behind coding, but I think that you're going to have to remember that these are Highschool kids, and it is highly unlikely that they will have the mathematical background to really dig into algorithms.
    I also disagree with people who are encouraging you to teach them languages such as Python. While it's true that there are languages that are much better than C at allowing you to get something impressive from a small amount of code, I think that it's detremental to students in the long run. After all, you aren't trying to specifically get these kids interested in programming, rather they are students who were interested enough to come to you.
    The biggest thing that I think you can probably do to give the kids a leg up is to focus on the lower level aspects of C. Do a good bit on memory allocation and debugging, and spent a lot of time on pointers. If these kids are interested in going on to become programmers, then making sure they have a solid grasp on pointers is probably one of the best things you can do.
    One of the most amazing things about kids is that, when they are cooperative, their minds are incredibly malleable. Take some of the hardest parts of programming, and start getting them to adjust their thinking toward it at an early stage, and you will find that they will become incredibly skilled programmers if they stick with it. Remember that given their mathematical background, there probably isn't a lot of point in trying to get too deep into analysing algorithms, and keep in mind that there is a lot of benefit to learning close-to-the-metal programming and they might not get it in a university (which seem to be focusing on Java more and more). Be sure to keep the assignments fun and challenging, and taylored to the things that they are interested in.
    The last bit of advice is that you should focus on more than just teaching them to code. Get them into the culture as well. In my programming class, for example, we used to have a weekly assignment to read and post to two stories on slashdot. We watched Revolution OS and Pirates of Silicon Valley. Get the kids into the hacker subculture and they will go much further as developers as well.

    --
    Famous Last Words: "hmm...wikipedia says it's edible"
  13. From a college grad who spent 4 years doing C ... by LSU_ADT_Geek · · Score: 2, Insightful

    I did my undergraduate at LSU in Computer Science, where they start off everyone in C. I have enjoyed the language as I have been able to transition to newer, high-level languages easily. Whether this is because of C or the mindset you need to have with C, I think teaching them C is a good way to start. As for materials on learning and working with C, I recommend the following books / websites: 1. C: How To Program by Deitel & Deitel (ISBN: 0-13-226119-7) (http://isbndb.com/d/book/c_a09.html) This is the first book I learned on. The 2nd edition does a real thorough presentation of material with lots of code and visual examples of good techniques. Also, the 2nd edition did a really good job of incorporating library headers and function prototypes, which are harder to find in a book. 2. The C Programming Language by Kernighan & Ritchie (ISBN: 0-13-110362-8) (http://isbndb.com/d/book/the_c_programming_langua ge_a05.html) This is the holy grail of C books since it was written by the original creators of the language. Despite its slim size, both Kernighan & Ritchie do a really good job with making it concise and relevant. I can guaranty that every C developer has this book on their shelf. It also has some information about interfacing with Unix/Linux OS. 3. Data structures and algorithms book in C I am sorry, I really meant to give you the actual book title I used but it is on my shelf at home. You want to find some type of data structures and algorithm book to enforce good design techniques. The biggest problem I have seen when people learn how to program is the fact they learn how to solve a problem only with the tools of the language. This makes them reluctant to move to other languages that don't provide solutions in the same mechanism. By having your students work in a lower-level language like C, they learn how to build the data structures taken care for you in other languages (stacks, queues, trees, graphs, etc) so they develop the mindset rather than a functional dependency. Hope this helps and keep up the good fight!

  14. C is an excellent choice by ciggieposeur · · Score: 2, Informative

    I'm going to buck a trend and say that C is actually a GREAT first language to learn:

    1. It has a simple way to do console and file IO (scanf, printf) that will enable students to write and test simple programs.

    2. It is used everywhere. As students learn more of C, they will be able to access and use the vast array of libraries available to C and go as deep as they want. When I was 16, it was common to learn C in order to start writing games, and then assembly language to make the fast loops faster. Another student learned assembly language in order to debug DOS viruses.

    3. It is completely deterministic when run in one thread.

    4. Its syntax is very simple. There are very few gotchas, most of which can be resolved with extra parenthesis.

    Everyone else saying "pointers suck", "use a simpler language", etc. are forgetting two things about that first programming language. First, no matter what language you start with, it will be difficult to begin programming. The learning curve for Lisp/Python/Java/Ruby/etc. will be at least as steep as that for C for new programmers, and additionally there is little point in teaching OOP to people unfamiliar with structured programming and the problems OOP is meant to address. Second, it is frustrating to learn a language that has little use elsewhere, especially when it is because someone else claimed that it was better to know general concepts than to know a useful language.

  15. Check out the ACM K-12 model curriculum by Stradivarius · · Score: 2, Informative

    The industry group Association for Computing Machinery has a model curriculum for integrating computer science into K-12 education. You might find some helpful ideas in there.