So, basically i'm new to programming especially in C. I can do web scripting, so I'm not completely new to the concept of programming.
But right now i'm a student in a computer engineering degree. I missed out on the C programming class I was supposed to take this summer, and one of the classes i'm in now will require basic C knowledge.
My goal is to actually become pretty proficient in programming using the C language, and what I would like to do is to get some more experienced programmers to give me ideas for simple programming that will help me learn some of the basics.
I thought that it would also be a good thing for other newbs too. That way there are like goals for them to try to reach // meet.
Opinions on this strategy, and anybody want to give me somewhere to start?
Thanks in advance,
One idea could be to solve certain programming challenges.
Such a site that could help you along is Sphere Online Judge (SPOJ) - Problems
This advice is based on my own experience; take it as you will.
The very first basics should come out of a book or tutorial. Those programs have very little practical value, except for illustrating the concepts and becoming familiar with the syntax. The first steps consist largely of reading, and the little programming snippets along the way are about supplementing those concepts, seeing them in action, and gaining familiarity with the language.
Once you start to get a basic grasp of the language, try combining the concepts you've learned into little practice programs - again, nothing practically useful but a way to get familiar with the language. The examples given in books/tutorials are good, but you'll advance faster if you tried a few out all on your own. Simple things to start, like having the user enter numbers and printing out the sum (or difference/product).
You hinted at something that was my biggest challenge when I first learned how to program - thinking of interesting ideas to code, for practice. Simple math functions and menu selection become boring on their own once I started to master them.
Some ideas to consider:
- Enter 10 numbers and find (then print) the average.
- Enter 10 numbers and find (then print) the largest and the smallest values.
- A simple (and very limited) calculator
- Find the result of the multiplication of two values, without using multiplication.
- A "cash register" program where prices are entered and totals are printed (with tax included)
- A program that takes an amount of money in "pennies" and produces the equivalent combination of dollars/quarter/dimes/nickels/pennies
- Blackjack (simplified)
- Hex to binary converter
- Resistor calculator (if you're into electronics)
- If you're into the old style RPGs (AD&D, etc), a program that rolls out stats for you
- Replica of any simple board games you might be familiar with
- A text-based "story" with different outcomes depending on user choices
- Find relatively simple standard functions and try to create your own replication of it
- A "phone book" that receives names and numbers, and stores them to a text file
- Make your own secret code by taking a string, and go character by character in the array to change one letter to another. Then convert it back to normal.
As you continue, the concepts become more advanced and you'll be able to do a lot more.
There's some debate about this, but my own learning curve sharpened immensely when I started trying to code basic ASCII "games." This helped solidify my understanding of multi-dimensional arrays, pointers and pointer arithmetic, using random numbers, algorithm solving, etc. Only using ASCII characters (and the common extended ASCII set), I created my own simple version of Snake, Tetris, Minesweeper, etc. I even tried a simple RPG that didn't really go anywhere, but was still a great learning experience.
Thanks for both of those answers! Matticus gave me some beginning problems to program, and the SPOJ looks like it will be nice once i've developed my skill set a little more.
Also, I am making my way through a book required for class, but the programs they are doing have to do with formatting right now.
One more thing, I see a lot of code on here using cout instead of printf.. Do they do the same thing? and which one would be better?
Now why would you inquire about learning C on the C++ forum? Mistake perhaps?
It was actually intended for the C programming language in general, covering most variants. C, C++, C# specifically.
Originally Posted by Elysia
Well, the first step for you is to pick one, then. :D
Originally Posted by Zach Sisk
Even if the choice is a blind one, stick with it....you'll find after a few years, after you can 'code', that learning a new one is quite trivial
(mastering each takes time though).
well since the thread has already been moved, i'll stick with regular C.
Also I found that cout must be for C++ and not C
Also could someone briefly explain the difference between like C, ANSI C, and ISO C, or if it is anything relevant.
C is a programming language.
ANSI C and ISO C refers to the standard that defines the C programming language.
ANSI C is the american standard for the language standardized by some US standard body.
ISO C is the international standard for the language standardized by the international body, ISO.
I am not aware of any difference between the ANSI and ISO standard, though. Still, follow the international standard and everyone will be happy.
FYI, this holds true for C++, too, though I don't know if there are any ANSI standards for C++ (there are ISO standards, however).
thanks. Right now i'm working on the practice problem of converting temperatures. And I think i'm doing pretty good for a beginner.
So far the problem i'm having is that if I provide say 95 and 90 with a interval of 2, I end up in a endless loop. Also I haven't implemented the high and low limits yet, but they are defined. Also haven't messed with conversions yet.
* File: main.c
* Author: zachsisk
* Created on September 14, 2012, 2:51 PM
#define UPPER 100
#define LOWER 0
int high = 0;
int low = 0;
int interval = 0;
int temp = 0;
printf("Please provide a temperature (Celcius) for the upper limit.\n");
printf("You provided %dC.\n",high);
printf("Please provide a temperature (Celcius) for the lower limit.\n");
printf("You provided %dC.\n", low);
printf("Please provide an interval.\n");
printf("You provided %dC.\n", interval);
temp = high;
temp = temp - interval;
}while (temp != low - interval);
Thanks for that. I really don't understand why tutorials tell you to type something that is considered bad practice and in most cases wrong altogether..
Use either while(temp > low); or while(temp >= low); You can't be sure that the interval will allow the temp to be exactly reached.
thanks for that advice. i'm not looking at the answer until I think I have something satisfactory. Then i'll compare and see if there are better ways to do it.
I didn't mean change the do while loop into a while only loop. I meant change the test at the bottom of the do while loop you already have there.