Langsung ke konten utama

Postingan

Menampilkan postingan dari Oktober, 2018

Pointers and Arrays

POINTERS AND ARRAYS SUB TOPICS : Pointer Definition Pointer Concept Pointer to Pointer Array Pointer Definition •        Pointer is a variable that store the address of another variable •        Syntax :                         < type> * ptr_name; •        Two operators mostly used in pointer : * (content of) and & (address of) •        Example: Initialize an integer pointer into a data variable: int i, *ptr; ptr = &i; To assign a new value to the variable pointed by the pointer: *ptr = 5;  / * means i=5 */ Pointer to Pointer ·            Pointer to pointer is a variable that saves another address of a pointer ·     ...

Program Control: Repetition

Program Control: Repetition Sub Topics : Program Control - Repetition: – Repetition Definition – For – While – Do-While – Repetition Operation – Break vs Continue Repetition Definition One or more instruction repeated for certain amount of time.  Number of repetition can be predefined (hard -coded in program) or defined later at run time Repetition/looping operation: – for – while – do-while For Syntax: for(exp1; exp2; exp3) statement; or: for(exp1; exp2; exp3){ statement1; statement2; ……. } exp1 :  initialization exp2 :  conditional exp3 :  increment or decrement exp1, exp2 and exp3 are optional While Syntax : while ( exp ) statements; or: while( exp ){ statement1; statement2; ….. } Do-While Syntax : do{ < statements >; } while( exp ); Keep executing while exp is true exp evaluation done after executing the statement(s) Repetition Operation In wh...