Skip to main content

Pointer and Array


Pointer and Array

Meaning of Pointer

A variable that store the address of another variable


Two operators mostly used in pointer :
  • ·         * (Content of)

So the (*) symbol in (*ptr) for example is used to point the content in ptr variable
  • ·         & (Address of)

The (&) symbol in (ptr = &x) is used to show where the x  address is

Pointer to Pointer (**)

A variable that saves another address of a pointer


So when the second pointer get the address of the first pointer using the (&) symbol, it ( the second pointer ) can point the content of that address using the (**) symbol.

Meaning of Array

A series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier
       Syntax:
                                type array_value [value_dim];
       Example :
                                int A[10];

           Elements of an array indexed starting from 0


Two Dimensional Array

       Syntax 2D Array:
                                type name_array[row][col];
       Example:
                                int a[2][0];

String

An array of character that ended with a null character ( ‘\0’ )
       Example :
                char s [  ] =  ”Makan”;                      
                Similar to :
                char s[ ] = {’M’,’a’,’k’,’a’,’n’,’\0’};

The fuction to manipulate string is ( #include<string.h> )

Comments

Popular posts from this blog

Cloud Storage

Cloud Computing atau nama lainnya adalah Komputasi Awan adalah teknologi yang menjadikan internet sebagai tempat penyimpanan database, aplikasi dan masih banyak lagi. Layanan Cloud Computing 1. Software as a Service (SaaS) Layanan pemakaian teknologi mengenai pemakaian software yang telah disediakan contohnya : gmail, outlook mail 2. Platform as a Service (PaaS) Cloud Computing dapat menyewakan sistem operasi, database engine, framework aplikasi untuk menjalankan aplikasi yang kita buat. Contohnya : windows azure  3. Infrastructure as a Service (IaaS) Cloud Service dapat memberikan layanan infrastruktur IT. Contohnya CPU, penyimpanan data, memory dan lainnya dapat disewa.  Cloud Deployment Model Deployment model define the type of access to the cloud. Type of access : 1. Private cloud       - Single organization only       - Managed by the org or a 3rd party       - On ...

Summary Semester 1

Assignment #1  1. Compound Word Jojo has just learned about compound words, which occurs when two or more words are joined to make one longer word. For example the English word footpath, composed of two words "foot" and "path". She wants you to make one such word, given two words that make up the compound word. 2. Birthday Cinema * Jojo, Lili, and Bibi wants to treat their N friends. They want to treat their N friends to watch a movie. Each movie ticket cost 1 point. Luckily there is a promo, if you buy 2 tickets you get 1 for free. How many points do they need to spend to buy tickets for all of them. 3. Counting Number Lili has just learned how to count from 1 to n, while Jojo just recently learned how to use a calculator. When Lili counts from 1 to n, Jojo always adds the numbers that Lili mentions. Jojo asked for your help to check if he used the calculator correctly, he needs you to calculate the number he is supposed to get. 4. Boom...

Function and Recursive

Function So, program is divided into modules. The modules in C programming language are execute using function. Function is a group of sentence that does a specific job. Function in C usually written above the int main() The benefit of using Function : 1. A huge program can be divide into smaller modules. 2. Easier to fix if there is a problem. 3. Easier to document Function Construction : return_type_value function_name  (  parameter-list  ) {    statement; } return-value-type :  data type of the value returned,  If not filled, then default data type will be used (integer) If return-value-type is void then the function will not return value Parameter-list : list of value sent from the function initiator (user) example :  int maximum ( int a,int b )    {      statement     } int : return value type of integer int a, int b : the parameter input by user statement : al...