Posts

Showing posts from October, 2018

Pointer and Array in C Programming Language

Pointer and Array pointer and array are two variables that are used in a similar manner, they are both used to connect data and address. despite their similar purpose, they have notable differences. pointer, by definition, store the address of another variable. They take different addresses as value. array, on the other hand, saves data in a structure to be accessed individually or as a group. All the elements are homogeneous, can be non sequential, and have fixed addresses pointer syntax :<type> *ptr_name example: ptr=i; *ptr=5. This means that i=5 pointer to pointer: ptr=i; ptr_ptr=ptr. *ptr=5. This means that i=5 **ptr_ptr=9. This means that i=9 or *ptr=9 array syntax : <type> array_value[value_dim]; This consists of a type, identifier, operator, and dimensional value example: int A[5]; this means that the array has 5 elements array can also be initialized without dimensional value declarations example: int A[]; {1,2,3,4}; this means the array ha...

Repetition and Looping in C Programming Language

Among the many things you can do in C Programming Language is Repetition and Looping Repetition When one or more operation is repeated over a certain amount of time The number of repetition can be predefined or defined later during the run time There are 3 types of Repetition/Looping Operator for while do-while For A basic operator for repetition Consists of three exponents an initialization a conditional an increments or decrements A for loop has no stop condition, meaning it is possible to loop operation infinitely by removing all the parameters. It is also possible to create a nested loop by creating a loop inside the loop, the operation will start from the inner loop. Example: for(x=1;x<=10;x++) printf("%d\n", x); This means the program will print the numbers 1 to 10 While and Do-While while and do-while are also repetition operators Despite their similar name, they are very different when it comes to operations, for example: while ...