Posts

Showing posts with the label C Language

4 Steps From Beginner To Advanced Level Of Mastering C/C++

Image
C and C++ Logo If you are just a newbie programmer, before you can jump and build a real application using C, you don't know how to get started or you just know very little about the syntax, the flow, the technique on how to do real programming in C. You can just begin your programming journey by learning some simple C code or to create small for just fun projects. Here is my experience doing some coding from scratch in C, level after level, from the easy to hard that I did. 1. Learning Pointer Manipulation In C Pointer is not an array, but a pointer behaves similar to an array. The difference is that an Array has an index while a pointer has an address to manipulate the value or the data in that specific address. A simple comparison diagram of Array and Pointer with respect to index and address can be seen in this diagram. You can learn more about pointers and with example codes from C programming pointers from programbiz.com here https://www.programiz.com/c-programming/c-pointers...

Linked List Data Structure Implementation In C Language

Image
Linked list is a data structure, a collection of data that each node in the list has reference to the next node and in a double linked list it can have a previous node. Linked lists are preferred to be used because of the efficiency in the insertion and deletion. Linked lists also can be used to implement other abstract data types  like stacks, queues, etc. The basic idea of linked list is that it has a head Node that we can iterate the next node until we find the very last node or the tail node to find specific data, usually given an index or the position of the data. In this post I created a simple reusable implementation of singly linked list in C, which probably is not very efficient in terms of speed and performance, but for me I feel like it’s much more human readable. Run Linked List Demo This implementation of linked list has features  that I will describe in a quick explanation below. - List_init To initialize the first node, or the head node if the linked list is...

C Pointer Program to get the last name from a full name

Image
C Language Flag / Logo Another C programming here, this article will simply explain how to do char array operation in C language to get the last word from a whole sentence, or in this case we just rename our function to be more specific to get a person last name from its full name. This is a very simple C function to get a user last name from a user full name. This function will do some pointer operation, so if you are trying to learn about pointer in C, this may help you little bit on understanding about a pointer in C: char * get_last_name(char * full_name) { char *last_name = full_name; int last_space=0; for(int i=0; i 0) last_space+=1; last_name += last_space; return last_name; } This function will loop through all the characters bit by bit and will try to find any spaces located on that character. If a space is found, then store the last space pointer location and return that pointer as its function return. - We define our function called get_last_name to ...

Recursive Function In C : Fibonacci, Factorial and Power of Numbers

Image
C Language Flag / Logo These are some example programs in the C language using recursive function to calculate Fibonacci, Factorial and Power of numbers. You can use a loop, but for a purpose of giving you an example on how to use recursive so we are going to use recursive instead. Fibonacci This is to calculate the sum of fibonacci numbers that are less than the specified number user input. int fibonacci(int number) { if(number == 0){ return 0; } else if(number == 1) { return 1; } else { return (fibonacci(number - 1) + fibonacci(number - 2)); } } - Our function accept integer, then we compare them using if statement - If the parameter number equal to 0, then the return of function is 0 - Also If the parameter number equal to 1, then the return of function is 1 - But if the number is not 1 or 0, this function will call itself with a new parameter for the first call is the parameter -1 and the second parameter -2, then add both results. - This ...

Popular posts from this blog

How to Install Microsoft Office on Your PC: A Step-by-Step Guide

Coding On Your Android Phone Using Termux

The Hidden Disk Hogs on Windows Developers Keep Ignoring (And How to Move Them to D:)