Securing Knowledge.

Continuosity on learning is the most important thing to secure your knowledge.

Wednesday, September 15, 2004

Function in C

Functions allow the programmer to modularize a program. The format of function definition is :

Return-value-type function-name (parameter-list)
{
declarations…..

statements…..
}


/*Function*/
/*Example -- A programmer-defined square function*/
/*Fig 5.13 -- page 147*/

#include stdio.h /* I’m not typing <> symbol cause its illegal in this blog*/

int square (int); /*Funtion prototype*/

int main ()
{
int x;

for ( x = 1; x <= 10; x++)
printf ("%d ", square (x)); /*calling a function*/
printf ("\n");
return 0;
}

int square (int y) /*Function*/
{
return y*y;
}

carrotsusu, 11:59 PM

3 Comments:

winter>huhu ade gak blog carrot nih. Meh la link ngan aku.. ^_^

http://silenteve.net
Anonymous Anonymous, at 5:32 AM  
oh mine.
C++.
cool
... my daily routine.
especially pointers. tuhan aja yg tahu betapa benaknya dulu, ;-)
.....
Blogger azizi, at 11:47 AM  
Onjey...

Dah lama tak code c++, asyik PHP, ASP....

azizi

Aku paling suka pointer.... heheh baru paham b'mana RAM komputer berfungsi.
Blogger Waqaf Ilmu, at 3:37 AM  

Add a comment