• 0

Learning to Programmer for Degree


Question

Hi all, I'm new to the forums although not new to the site, been using for a few years, I've registered to ask a few questions regarding programming, I'll start with a bit of background first.

I've always been interested in computers from an early age so I did a National Diploma in IT at college, I was a bit young and didn't make much effort, In any case I passed but not with a very good grade. As well as being interested in computers I've always had a passion for music so after taking a year out I went back to do a music course, whilst I was there I decided to try and bump up my computer course grades, and managed to do so with triple distinction (the equivalent of 3 A's) I then went on to do music technology at University, around the first term I decided music wasn't for me (realised I could do better in a more academic course) and chose to pursue computing, I applied for a Forensic Computing course to start this September but also completed my first year in Music Technology as it would have been a waste to just drop out.

Sorry for all the rubbish which you probably don't care about, but anyway, I start the Forensic Computing course In September.

On the course they teach C programming language, I want to get a head start and have bought the book entitled: "C Programming In Easy Steps" by Mike McGrath. I Have read and understood the book vaguely.

I want to start programming to give me the knowledge, yet I just don't know what to program?

Is C a good language to start with? should I maybe learn a more basic language? (If there is any)

I keep thinking to myself that before I can really learn to programme, I have to have a need for programming (In this case it is just my course, although I am intrigued just to learn)

The only experience I have had in programming is Adobe Director scripting.

Thanks for reading, and I hope someone can shed some light on the subject for me.

Link to comment
Share on other sites

19 answers to this question

Recommended Posts

  • 0

C is alright to start with if you have experience with programming concepts (variables, loops, functions, etc). I started with a scripting language (mIRC's language, to be exact) and from there moved on to PHP, followed by VB6, VB.NET, C, and then C#. Once you learn the concepts, learning a new language is as simple as learning its syntax.

You don't really have to have a need to program if you want to learn. Start making easy things and following examples. Eventually you'll get an idea for something you'd like to work on. Then you can do a little research about the best way to do it in your language of choice.

Link to comment
Share on other sites

  • 0

Any sufficiently mainstream programming language is a good start. Since they teach C at your school, you might as well pull ahead now so it'll be easier and more interesting when you take the class. As soon as you feel like you have a good grasp on C, try another, very different language, maybe Java or C#. Understanding a second language will help you put C in perspective and make your own opinion about what language to use for a given task.

As for ideas of programs... what do you like about software? I've always loved games so when I learn a language I usually try to make a little game in it. You'll have to make use of many features of the language to do it so it's a good tutorial. A simple hangman or tic-tac-toe on the console is a very good exercise.

As for books, allow me to suggest the C Primer Plus by Stephen Prata. There's no better introduction to the language IMO.

Link to comment
Share on other sites

  • 0

Starting with a object oriented language and then go back to C is a bad idea, so start with C then go with higher level object oriented languages like Java, C++ or C#.

The easier to learn in VB.net (visual basic), but going to C after learning it will feel like jumping from the second floor to the basement ;). Good luck with C, once you master it, it is the best language for low level apps/hardware stuff/embedded stuff/background process/critical applications.

Link to comment
Share on other sites

  • 0
Starting with a object oriented language and then go back to C is a bad idea, so start with C then go with higher level object oriented languages like Java, C++ or C#.
I completely disagree. If you take C and C++, for instance, C is basically just a subset of C++. If you can understand C++, C is basically the same thing minus objects and the STL. The transition from C to C++ is way harder than from C++ to C (many never do it!). Also I think it's best to learn good OO practices from the start; since habits are hard to get rid of, you might as well develop the right habits.

The only argument for C is that it's "closer to the metal", so you better understand the implications of memory allocation, object copying, etc. when you work with a higher-level language. It has nothing to do with object-orientation.

In this context I suggested C because that's what they teach in his first class. I still think that the sooner away from C, the better (hence my suggestion to learn a second language asap).

Link to comment
Share on other sites

  • 0

Cheers for the advice guys, going to check out that book now, the one I have lacks real examples to follow so it's hard to take it all in, when I was learning Adobe Director, the book I had, had extensive examples and helped me learn the language thoroughly in very little time, I guess I need something in a similar vein, but for C.

Link to comment
Share on other sites

  • 0
Starting with a object oriented language and then go back to C is a bad idea, so start with C then go with higher level object oriented languages like Java, C++ or C#.

Elv13++

As I've said before, in my experience when tutoring, it was easier to start with the bare basics and build up (so it's easier to see why the higher abstractions are needed, what the abstractions of the higher languages are trying to achieve, and why they are what they are; understand that makes it possible to grasp the higher-level languages at a much deeper level). This still somewhat works going the other direction, but not as well.

That having been said, equally important is having a reason to program. I know that when I started learning to program, it basically didn't work because none of the stuff that I read stuck since it all seemed to abstract and far away. I didn't actually learn to program until a year later, when I entered the 7th grade and got tired of factoring polynomials by hand, so I learned TI-basic from scratch wrote a program to do my homework for me, all in a few days. Never underestimate the importance of having something to build towards, and the difficulty of doing that in C is one reservation that I have about fully endorsing C as an intro language.

Link to comment
Share on other sites

  • 0

I'm somewhat torn as to which is a better first language (C vs Java). C is much simpler, however it is less forgiving than Java. Java gives you nice error?s and will hold your hand and tell you ?no no no, you?ve over run the bounds of your array?. Whereas C relies on the programmer to catch a lot of those dumb mistakes. However Java introduces OO concepts, which can be too complex for first time programmers.

My college taught us Java then C, but I had a class in high school that taught C++ while avoiding OO concepts.

Link to comment
Share on other sites

  • 0

It really depends on what you want to program. Probably the easiest start is Microsoft Visual Basic .Net. It's easy to develop using Visual Studio IDE.

Here's the free version: http://www.microsoft.com/express/vb/

You probably will not need the full blown VS so it's perfect.

Here's some nice introductory videos on programming VB: http://msdn.microsoft.com/en-us/beginner/dd435692.aspx

Hello world is as easy as this:

TextBox1.Text = "Hello, World"

Link to comment
Share on other sites

  • 0

Agreed that it's probably easier to start with c. I first encountered programming through MS Office's VBA, which I used to solve practical problems in a research lab. Then the .NET framework came out, so I delved into VB .NET. Now I'm using C# along with occasional C++. I'm not a serious programmer; I just use it to make things easier/quicker at work and at home.

Learning to use C++ is extremely difficult for me at this point because it's extraordinarily frustrating compared to using C#, yet a lot concepts in C# can be implemented better by understanding basic c concepts.

And definitely start with a well-reviewed book if you're serious about it. I rarely encounter good tutorials online and there's a lot of bad practice out there.

Link to comment
Share on other sites

  • 0
Never underestimate the importance of having something to build towards, and the difficulty of doing that in C is one reservation that I have about fully endorsing C as an intro language.
You make a good point. I only learn what I need to know to makes things work for me. And how about this for something to build towards: one of my friends in college learned programming purely to use it in the financial arena. He got hired by Goldman right out of college for $650,000/year to write code that analyzes stock prices in real time and makes automated transactions base on micro-trends (coincidentally, one of his colleagues was arrested by the FBI last week for going AWOL with some of the code). He jokes that his $2400 computer makes G-S tens of millions per year; that's probably not far from the truth, though I'm guessing they run his code on a cluster that costs a little more than $2400. I laugh about that every time I watch one of our IT guys, with all their programming knowledge, spend all day telling people how to use the Windows control panel.
Link to comment
Share on other sites

  • 0

It's going wrong already :(

When I compile and run this:

int main() {

int num;
char character;
float decim;
double longnum;


printf("Please enter an integer: ");
scanf("%d", &num);
printf("Please enter a character: ");
scanf("%c", &character );
printf("Please enter a decimal correct to one decimal place: ");
scanf("%f", &decim);
printf("Please enter a 6 digit number: ");
scanf("%ld", &longnum);

printf("The integer you entered was: %d\n", num);
printf("The character you enetered was: %c\n", character);
printf("The decimal you enetered was: %f\n", decim);
printf("The long number you enetered was: %ld\n", longnum);


return 0;
}

The output is a bit weird, it fails to ask you for the character and goes straight to the decimal:

Please enter an integer: 5

Please enter a character: Please enter a decimal correct to one decimal place:

Any ideas? or should I just shut shop and give up :(

Edited by aydinh
Link to comment
Share on other sites

  • 0

The input isn't properly flushed after the first scanf so the second uses what's left. Use fflush(stdin) to clear the input buffer after each scanf.

Generally speaking when you want to input a single character, use getchar().

When you want to input several characters, declare an array of characters and specify "%s" in scanf.

like so :

char string[20]; // holds a maximum of 20 characters
scanf("%s", string);

See http://www.cplusplus.com/reference/clibrary/cstdio/scanf/

and http://www.cplusplus.com/reference/clibrary/cstdio/getchar/

Btw, use code tags when you post code, it makes it easier to read.

Edited by Dr_Asik
Link to comment
Share on other sites

  • 0

I only have programmed in Java (took only two classes, so I know the very basics)...

But maybe the space after the character variable in "scanf("%c", &character );" is throwing it off?

Link to comment
Share on other sites

  • 0

Nope, just tried and it didn't work, thanks anyway.

Another problem also, atm I'm compiling in Ubuntu with GCC and it works fine, but when I compile with GCC in Windows (Windows 7 RC) and try to run I just get a "Program too big to fit in memory" error, I have ample memory (4GB) and I am only trying to run the program pasted on the previous page.

Using GCC version 3.4.5

Link to comment
Share on other sites

  • 0

Ok well sorry for the inexact advice. fflush(stdin) is undefined, it works in certain environments/compilers and not others.

The problem here is that basically, scanf sucks. It leaves junk in the input buffer, so the next time you call it, it doesn't wait for user input and uses what's left in it.

The clean way of doing input in C is to use only getchar() with a loop and parse it yourself. scanf is evil.

Here's an example of properly handling user input in C: http://gd.tuwien.ac.at/languages/c/program...brown/c_055.htm

Most programming languages have decent I/O facilities, unfortunately, C is not among these. :p

Edited by Dr_Asik
Link to comment
Share on other sites

  • 0

my 2c to you

so, i got accepted earlier this year to a program called MEET where we learn java every summer for 3 years from MIT graduates, its really great, and intensive program (9 am to 5:30 5 days a week x4 weeks x3 summers + yearlong program).

java is a GREAT language to start with objects, i dipped my toes with so many languanges and only gone ahead with maybe PHP and VB 6, i must tell you no matter how many books i read, i think i didn't scratch the surface with my understanding of programming until actually starting the course, the concepts are so diffcult to understand from a book, its just extremely diffrent, i would suggest if you wanna dip your legs in water before your class sign up to some course somewhere, maybe for a diffrent languange, its worth it, hell it is.

also, i would recommend java for learning OOP, its great.

my tip to you is: don't get stuck on technicality's and syntax first, REALLY get the concept, if you will get stuck on syntax etc, you will make a huge mistake and won't fully understand the concept of programming in my opinion, if you want to learn from a book, pick up a general book, one that teaches concepts and sometimes maybe throws examples in some few languages, that's what you need i think, i bet someone here has a book to recommend for you ( i have 1 but its in Hebrew, and i bet you can find a better one in english)

Link to comment
Share on other sites

  • 0
Nope, just tried and it didn't work, thanks anyway.

Another problem also, atm I'm compiling in Ubuntu with GCC and it works fine, but when I compile with GCC in Windows (Windows 7 RC) and try to run I just get a "Program too big to fit in memory" error, I have ample memory (4GB) and I am only trying to run the program pasted on the previous page.

Using GCC version 3.4.5

Your error in Windows 7 RC could be well due to the fact that it's just an RC... What are you using, command-line, eclipse, Code::Blocks, DevC++ ? In my experience using GCC in Code::Blocks works fine under both XP and Vista. The easiest under Windows is to use Visual C++ Express 2008 though, it has a great debugger and it's fairly industry-standard.

Don't let yourself be discouraged by the pain of I/O in C. In most programming languages it's much easier, and you get the hang of it in C, you'll already have a big step accomplished. :)

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.