Sabtu, 17 Oktober 2015

Function on C Programming

What is Function?

Function is a feature or tool used to wrap one or several computational processes and supporting information, to complete an action or process of computing based on its usefulness.
From the definition above, it can be concluded that the function is a special tool that can take action to solve specific problems. The point? The intent of the sentence can be understood from the use of the function. Still confused? Here the example of a function that must have been frequently used in writing programs in C language, printf (), getchar (), scanf () is a function that we can use to solve or handle a process, and each of these functions has a way of working  :)
Declaration and Usage
A function declared as below

return_type function_name (parameter_declaration, [second_parameter_if_any)
{
  declarations_variable;
  statements;
}

return_type is the data type of a function declared. This data type is the main thing that must be considered in making a function or a function, Okay, then how to use the functions that we make? In general, if we want to use a function that we have previously made, we simply call the name of the function and the function will only work by itself. So we do not have to worry about how the function that implement what we are told, because the C language already has its own way to handle it, which is important for us is how to make a function properly.




Note the declaration and use of function in the program code above. Authors declare two functions with different return type to be used in the program, for a declaration written before function main ().
Then, consider the declaration of a function is  different . The main difference in the type of data and functions that define the parameters of the function.
At the time of declaring the function, the variable naming parameter is not an important part, the most important is the data type of the parameter. Okay,  code for the function that has been declared previously in the lower part (after the function main ()). Naming the variable parameters to be used.

How Recursion Works with example in C

Recursion is a process that calls the process back. Recursion in C language functions are realized in the form of one or more instructions are dialing instructions to call a function that returns either directly or indirectly. Function which is called the recursive function. I use software C Compiler Dev C++
Example of recursion in C Programming

Write a C program to find sum of first n natural numbers using recursion. Example :

















Output :


in the program c on top, sum() function is invoked from the same function. If n is not equal to 0 then, the function calls itself passing argument 1 less than the previous argument it was called with. Suppose, n is 5 initially. Then, during next function calls, 4 is passed to a function and the value of argument decreases by 1 in each recursive call. When, n becomes equal to 0, the value of n is returned which is the sum numbers from 5 to 1.
The following explanation above recursion :

sum(10)
=10+sum(9)
=10+9+sum(8)
=10+9+8+sum(7)
=10+9+8+7+sum(6)
=10+9+8+7+6+sum(5)
=10+9+8+7+6+5+sum(4)
=10+9+8+7+6+5+4+sum(3)
=10+9+8+7+6+5+4+3+sum(2)
=10+9+8+7+6+5+4+3+2+sum(1)
=10+9+8+7+6+5+4+3+2+1+0
=10+9+8+7+6+5+4+3+2+1
=10+9+8+7+6+5+4+3+3
=10+9+8+7+6+5+4+6
=10+9+8+7+6+5+10
=10+9+8+7+6+15
=10+9+8+7+21
=10+9+8+28
=10+9+36
=10+45
=55
   
Every recursive function must be provided with a way to end the recursion. In this example when, n is equal to 0, there is no recursive call and recursion ends.

Jumat, 16 Oktober 2015

Tutorial Array in C Programming

Array is a container for a number of the same type of data and the use of the indentifer. because the array is the reservoir of data, so the array is variable. Different from the usual array of variables are at kapasits reservoirs. a variable of type int can only hold an integer. bertype char variables can only meampung an ASCII character. An array of type int can hold a number bulat.larike of type char can hold a number of characters ASCII.masing each data element array is accessed by using the index or sub script.index array always starts from zero to n-1, with n states the size or capacity of the array

Array is a type of structured formations (structured user-defined types). Array or array needed to store a series of elements of the same type, structured homogeneous (homogenous structure), which is called type base (the base type).

Array also called structure that can be accessed randomly (random-access structure) because all elements of the array can be referenced at random with certain rules, namely by knowing the serial number called an index (index).


This situation can be illustrated as a student dormitory rooms, each room has a serial number and is inhabited by a student. A student can be distinguished by the serial number of room. Student dormitory Student dormitories as an array, the elements of the same type, namely a student dorm, and the room number is the index.
Arrays are of two types:

One-dimensional arrays
• Each element of the array can be accessed through an index.
• default array index starts from 0.
• The general form: Tipe_array nama_array [size];

Example program to input the value of students into a one-dimensional array

Output:





Two Dimensional arrays

• Two dimensional array is an array consisting of n rows and n columns.
• The form can be either a matrix or table.
• Declaration array: Type_array nama_array [row] [column];


Examples of program input the value of [number] into two-dimensional arrays and displays.


Output:


















Summary:
Two-dimensional array is an array consisting of m pieces rows and n columns, which form can be either a matrix or table. So that the results of their input so the same, but its output is different from its value.

Examples of two-dimensional matrix summation program





Output :




















Summary:

In a two-dimensional array is an array consisting of m pieces rows and n columns, and shaped in the form of a matrix or table.

Multy Dimensional Array

• multi-dimensional array is an array that has the size of more than two. Shape and array declaration is tantamount to an array of one-dimensional or two-dimensional array.
• The general form:

tipe_array nama_array [Dimensions1] [ukuran2] .. [ukuranN];


Example of Multidimensional Array In C

Write a C program to find sum of two matrix of order 2*2 using multidimensional 

arrays where, elements of matrix are entered by user.






Ouput
Enter the elements of 1st matrix
Enter a11: 2;
Enter a12: 0.5;
Enter a21: -1.1;
Enter a22: 2;
Enter the elements of 2nd matrix
Enter b11: 0.2;
Enter b12: 0;
Enter b21: 0.23;
Enter b22: 23;
Sum Of Matrix:
2.2     0.5
-0.9    25.0

Sabtu, 03 Oktober 2015

Tutorial on looping/iteration in C/C++

Hi, This time it is a tutorial that explains about looping , Keep the spirit!
1. The first thing to do is open his program and start making the file by clicking the File > New > Source File or just press C + N on the keyboard
 2.there be open a blank new project
 3. Immediately start ya! , the description letter
 4. Dont forget to save before compile . I named looping and save
 5. After that , Compile and Run or just press F11 key on the keyboard
 6. And the process is finished Compile not waste a long time because it is only a simple coding .
  its also the basic coding . Compile dialog box is located under the log , which records all the      compilation file storage come from , if there is an error or not.
7. The program was immediately execute , the coding above I make a repetition of a command printf ( " Looping ........ !!! " ) ; 10 times , which means that the program will be to print as many as 10 times without us manually printf 10 times , practical right? Looping can also be combined with
 examples before that user- input- ouput , or use if else condition .thats all from me.
 Stay spirit and do not give up !

Tutorial on decision/branch in C/C++

Meet again with me at tutorial about decision , I would make the project a condition of using the if else if . lets start!
1. First, open program Dev C ++ , just opened and just click the menu File > New > Source File or just press CTRL + N ok the keyboard
2. The new file is already open , truly new and empty like a blank white paper
3. If already create a new file , we just started to make a program if else condition . Follow coding on the picture and consider each word of program because it is sensitive to typo user

4. Notice the word is right.before compile must save first. We give a name file "decision" Then Click Save.

5. then click Compile and Run button or just press F11 on the keyboard

6. successful compilation. the program will directly open . In this program I made three conditions where the first condition that b < 0 is negative , while b == 0 is zero and b> 0 is positive , still dont understand ? Need a picture ? See below ya!



7. Already know? what is a function if else on a programming . This is the basis of programming where a large project
 that will help you later on . Good luck and dont ever give up just because the hard coding .
 Make coding is a pleasure and not a burden to live

Tutorial of each data types in C/C++, reading input from user, writing an output, input redirection "<" for faster testing

Hi my name is Lia Kurnia Sari , this time I will give an example of a C language program that is user- input- output . 
The point is that the program allows the user to input the data and displays the data entered by the user.Clearly see the tutorial below ya
1.First Open Dev C ++ , and will appear as blank, we click File > New > Source File or press CTRL + N on the keyboard
2.Then a new file will appear , it is empty there is no anything

3.Continue just follow the scripts on the picture

4.before compiled , the file must be saved first. We give the name of the project this time by the name of user- input- output then save
5.After that compile and run the program or press F11 on the keyboard
 6.And the program is successfully compiled , at the bottom there are compile a log that displays activity is running smoothly or have some error . And the program also automatically open because we had direct Compile and Run .  On the program explained that it asks the user to input the data
7. We can try to input the data ,try integer or numeric data input , example 5
8. And the program immediately displays that was input by the user . On the program using scanf and printf where  scanf like textbox with name textbox is c , where on top of its already made variable c . 
 Then called scanf for input of data and come up with the c variable data using print
9.that is my tutorial at this time , hopefully can help the beginner who wants to be a programmer.

Tutorial how to create a hello world program in C (the explanation of each part of the source code), compiling, reading the compiler errors, running the compiled program

This time I will make the simple coding to use printf , to more clearly see below ya !
1. if Dev C ++ application is installed , it's time now to make a simple project
2. Open Dev - C ++ applications such as in the picture below , this is the first appearance that you will see when the application is open . And we just create a new project by clicking File> New > Source File or just press Ctrl + N on the keyboard
3. there will open a blank new project,it the place where we will make coding

 4. follow the coding as shown.

 5. after that , just Compile and Run or just press F11 key on the keyboard
6. Before compiled , the file should be saved . named Hello to select the file extension .cpp . .cpp is an extension to the C ++ language files while the c language select .c . then save

7. And the process of compiling and run is finish. Below are compiling a log which will tell whether the compilation was running  perfectly without error or not error . Then will appearance command prompt , it is an application that we just created by using printf ( " Hello World !! " ) will be presenting  text Hello World !! . so easy right ?, try it and good luck guys!


Step by step tutorial with screenshot how to install C/C++ compiler

Welcome, at this time I will explain about how to install C/C++ Compiler, I use software Dev C++
1. Open Dev C ++ application that was downloaded ,then immediately open the application and notification appears as in the picture directly OK .       
2.there will appear the language option , then choose english then OK
       
3. there will appear to agree to display a license agreement , and select I Agree
4. Choose a storage location after that click install

5. wait until the installation process is complete
6. The installation complete, click Finish . There is a Checkbox where if you checked it will automatically open Application Dev C ++ and if you unchecked it will not open the application . if you want to check or not , it does not matter because in this process , the installation is complete and the application can be run at anytime