Wikipedia

Hasil penelusuran

Minggu, 18 Oktober 2015

Arrays In C

  • Array is a way to store variables in contingous space, that can be looped later
  • Use Array when the number of inputs to be stored are too many 
 
Since Example is The Best Teacher for me, lets look at this example :

 Look at the pic : 






we can also write it this way :











To know the size of your Array, you can use function "sizeof" and divide it by one element of the array.

example :



Hope This Will Help
Peace !










Sabtu, 17 Oktober 2015

Recursion / Recursive Function in C

  • Recursion is the process of repeating items in a self-similar way. Same applies in programming languages as well where if a programming allows you to call a function inside the same function that is called recursive call of the function as follows.
 here is a basic example about how recursion works




This program ends when we've counted to twenty, or more precisely, when count is no longer less than twenty. This is a good base case because it means that if we have an input greater than twenty, we'll stop immediately. If we'd chosen to stop when count equaled twenty, then if the function were called with the input 21, it would run out of memory before stopping.

By the way, i wrote the function name as count_to_ten ., actually it should be count_to_twenty . but its just a name given by us, so i guess its okay. i forgot to modify that one

source  :
Tutorialspoint   : http://www.tutorialspoint.com/cprogramming/c_recursion.htm 

Cprogramming : http://www.cprogramming.com/tutorial/c/lesson16.html 


Hope this basic recursion example helps.
Peace!
  

Jumat, 16 Oktober 2015

Function , Arguments/Parameter in C

  • Function can be described as a group of Code to do specified things. 
  • Argument = Parameter of the function 

Defining a Function

return_type function_name( parameter list )
{
   body of the function
}
 

  •  Return Type: A function may return a value. The return_type is the data type of the value the function returns. Some functions perform the desired operations without returning a value. In this case, the return_type is the keyword void.

  • Function Name: This is the actual name of the function. The function name and the parameter list together constitute the function signature. 
     
    • Parameters: A parameter is like a placeholder. When a function is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a function. Parameters are optional; that is, a function may contain no parameters. 
      • Function Body: The function body contains a collection of statements that define what the function does.
       


     To make it clear, Lets Jump to Code::Blocks


    Function is not always placed before int main ().
     Every function usually have the return value,
    i have explained it on the pic . 


    Here's an example without using return value,
     usually we call it as a procedure. 


    source : http://www.tutorialspoint.com/cprogramming/c_functions.htm

    Hope This Basic Functions will Help.
    Peace!













    Kamis, 01 Oktober 2015

    Looping/ Iteration in C Programming

    Sup' guys, today im going to share about Looping And Iteration In C Programming.
    Loop is actually Looping, it allows you to iterate something until specified times, and stop at specified point.
    to help you understand, see the Loop / Iteration Flowchart below:

     

    in Looping, Basically i use :
    -While
    -For
    -Do-While

    i'll explain all of it to you , starting with 

    While .
      for me, Example is the Best teacher. so ill give the example directly to you , jump to Code::Blocks !

    *this example is about finding the average glass of water drunk per day in a week.







     For.
    *same example





    Do-While.
    *same example


     Basically, Do While is a bit similar to While
     the difference is in While, you state the loop condition first then give instruction. but in Do-Whle , you do the instruction first , Then state the loop condition
    Example:


      Hope this Helps 
    Peace !