PDA

View Full Version : Lesson 03: C Programming


x-pert
07-06-2007, 07:27 PM
Please read lesson 01 (http://www.elakiri.com/forum/showthread.php?t=35788) and lesson 02 (http://www.elakiri.com/forum/showthread.php?t=35876) to get a clear idea befor reading this....

Thought to start this lesson with some words of ma mate L Flon. :lol:
He once said.... “There is no programming language, no matter how structured, that will prevent Programmers from writing bad programs.”

Keeping that in mind... Lets start this.

OK... First thing first. How to insert a comment to the codings and what is the purpose of inserting comments to your codes.

You might think that programmers will always write codings. No guys. That’s a myth. :D

Far more time is spent maintaining, upgrading and debugging existing code.

Actually according to my data sources the amount of time which we spend in maintaining is skyrocketing.

From 1980 to 2000 the average lines of code went from 23,000 to 2,200,000. The average age of an application went up from 4.75 years to 11.3 years.

So just the same as a human.... Source codes also should be maintained within its life time.

When comes to maintaining codes, there are 2 big big problems which we have to face.
1) Code is difficult to correct, coz the authors even can’t understand it.
2) Modifications or upgrades are difficult to make coz the programmer should spend a considerable amount of time figuring out what the program does.

To make your coding more readable and more understandable, you have to include comments appropriately. Usually it is recommended to have 40% of your lines of code as comments. :P

Comments in C language starts with a slash asterisk (/*) and ends with an asterisk slash (*/).

/* ************************************************** *****
* hello -- program to print "Hello World". On the screen.*
* *
* *
* Author: NRYDDS a.k.a x-pert. *
* *
* Purpose: Demonstration of a simple program. *
* *
* Usage: *
* Other comments: exclusively from http://www.elakiri.com *
* *
* Runs the program and the message appears. *
************************************************** ***** */


#include <stdio.h>
int main()
{
/* Tell the world hello */
printf("Hello World\n");
return (0);
}



In the above example, I have Bold the start and the end of the comment.
All the characters which are between those two points belong to the comment.


These types of comments are called ‘comment boxes’.

Less important comments are not boxed.
Such as /* Tell the world hello */ in the above example.



Some commenting styles as in: Oualline, S. Practical C programming, O’Reilly Publications

/************************************************** ******
************************************************** ******
******** WARNING: This is an example of a *******
******** warning message that grabs the *******
******** attention of the programmer. *******
************************************************** ******
************************************************** ******/



/*------------> Another, less important warning <--------*/


/*>>>>>>>>>>>> Major section header <<<<<<<<<<<<<<<< */


/************************************************** ******
* We use boxed comments in this book to denote the *
* beginning of a section or program. *
************************************************** ******/


/*------------------------------------------------------*\
* This is another way of drawing boxes. *
\*------------------------------------------------------*/



/*
* This is the beginning of a section.
* ^^^^ ^^ ^^^ ^^^^^^^^^ ^^ ^ ^^^^^^^
*
* In the paragraph that follows, we explain what
* the section does and how it works.
*/



/*
* A medium-level comment explaining the next
* dozen (or so) lines of code. Even though we don't have
* the bold typeface, we can **emphasize** words.
*/
/* A simple comment explaining the next line */

nEoN_wHitE
07-06-2007, 07:28 PM
ho ho ho.. u done it again:D:D:D:D
thanx macho:D

x-pert
07-06-2007, 07:56 PM
Ha ha Ela Ela.... dammata kauruth balanne naha :lol: :lol: :lol: :lol:

Ekek hari igena ganeene kiyala hithala daanawa ithin.... ha ha :P :P

tckrockz
07-06-2007, 07:59 PM
ahh mama ada idan patan ganna onnaa ube lessons follow karaa

x-pert
07-06-2007, 08:01 PM
ahh mama ada idan patan ganna onnaa ube lessons follow karaa


Ah :D :D :D :D Ela Ela...

Anna lesson 04 th damma mama.. heta withara daanawa 5 and 6....

Okkoma 20yi thiyanne... ;)

Lich
07-06-2007, 08:35 PM
Finished it.. thanks a lot.. waiting for the Next Lesson..

sanjaya
07-06-2007, 09:01 PM
Ha ha Ela Ela.... dammata kauruth balanne naha :lol: :lol: :lol: :lol:

Ekek hari igena ganeene kiyala hithala daanawa ithin.... ha ha :P :P


ado machoo tekak Advance program ekak dapan katteyata eganaganna (kateyata Loops keyaladena for,if,while) :yes: :yes: :yes:

anyway good work bro :rolleyes: :rolleyes: :rolleyes: :rolleyes:

x-pert
07-06-2007, 09:03 PM
ado machoo tekak Advance program ekak dapan katteyata eganaganna (kateyata Loops keyaladena for,if,while) :yes: :yes: :yes:

anyway good work bro :rolleyes: :rolleyes: :rolleyes: :rolleyes:


Iwasapan yako... hehe :lol: :lol:

Naha bung.. basic idalama yanna hadanne.. ethakota ooni kenekta mula idalama yanna puluwan nisa....

Hoda hoda eewa eli wena jaameta kiyala ahala theenawa neda uba... ;) ;)

Thanks bro... :cool:

sanjaya
07-06-2007, 09:06 PM
Iwasapan yako... hehe :lol: :lol:

Naha bung.. basic idalama yanna hadanne.. ethakota ooni kenekta mula idalama yanna puluwan nisa....

Hoda hoda eewa eli wena jaameta kiyala ahala theenawa neda uba... ;) ;)

Thanks bro... :cool:

kasteyata boren weida danne na machoo :D :D

x-pert
07-06-2007, 09:09 PM
kasteyata boren weida danne na machoo :D :D


Owu ehema case ekak thiyanawa... uba balapanko mama damma 4th ekath.. ethana idala digatama codings thamai... :cool:

ICE
07-06-2007, 09:25 PM
ela kiri macho...

digatama daapan....

x-pert
07-07-2007, 07:42 AM
Daala wadak thiyeyida bung... kauruth balanne naha wagee ne :P :P :P :lol: :lol:

ICE
07-07-2007, 07:46 AM
Daala wadak thiyeyida bung... kauruth balanne naha wagee ne :P :P :P :lol: :lol:

umba salenne nathuva daapan ko.......:lol: :lol: :lol:

thama mula hariye ne....

honda honda sellam elivena jaameta ne...:lol: :lol: :lol: :lol: