Still on C. Today's classes were as followed:
09:30-10:30 - C Lab
10:30-11:30 - C Lecture
11:30-13:30 - C Lab
14:30-15:30 - C Lecture
15:30-16:30 - C Lab
Entah I don't know why they put the classes like that. To give time for other people to use the rooms kali? Yesterday's schedule was the same. Went through the lecture notes during lectures, up to Chapter 4. Oh have I mentioned that they are so many chinese from China in the course? I was waiting for the lecture to start and went in early, and there were only 2 orang putih, and the rest were Chinese. I felt like I was studying in China huhu. I remembered once in Birmingham where there was no orang putih langsung jua in the computer lab that time, only Indians, Arabs.. you get the drift, yang jenis catulah. Masa atu macam di negeri lain jua ku rasanya =P So anyways, lectures of course made me dozed off a few times. *yawns*
In the lab sessions we just did the exercises for the chapters we went through in lectures. I did up to Chapter 4, but haven't finished all of the exercises in that chapter. I stopped at the second exercise of chapter 4. It asked for a program that prints out prime numbers according to the number of times input by user. I was tired of thinking Maths, so I stopped lah. Macam inda keluar lagi apa2 formula dari kepalaku tadi atu, Maths tah lagi. The first exercise on Chapter 4 was to write a program that prints out sequences of hailstone numbers according to the number of times input by user. I didn't know what hailstone numbers were, confused tia ku, dengan formula2 yang keluar lagi. Even more confusing =P But I managed to do it and got everything correct except for one problem where my second value kept on repeating itself instead of changing to another new value. Called the lab supervisor and he helped me fixed it. Sekali so simple to fix! Sasak plang ku benda simple inda ku tebuat. I'll continue with the prime numbers program tomorrow, if rajin. Cause tomorrow lectures are cancelled as the lecturer felt we probably got enough of programming by now. Faham pun ia. So I might not come to labs kali, tidur tah ku kali rasaku.... -_- Or I might come in late for labs. But I'm not sure, I think he said that the lab will only be on from 09:00-10:00 and nada masa afternoon. And I don't feel like going up the hill for a 1-hour class. So... =)
Bah sambung. So lay your program this way if you want to gain more marks in the assignments and coursework, according to the lecturer. And besides it'll make your source code looks tidier:
- Don't forget to include comments. First put them on top, then put them anywhere else necessary.
- Second comes #include
- List of function prototypes - must be on top and before main() function.
- After that comes main() function.
- Then all other functions mentioned in function prototypes.
And never ever forget curly brackets { and }, especially in loops.
Other stuff:
- stdio.h - used when you're going to print something out or get input from users
- stdlib.h - for including other functions in the standard library, eg rand()
- When using scanf(), don't forget to include ampersand in the argument.
- A for loop can be changed to while loop. When writing one of them, check to see if you can change it to the other loop.
Tata.