# Given two linked lists, both represent a number need to find its sum linked list.

As described in problem statement, we have two linked lists represents as decimal numbers. We aim to find its sum as a linked list. Let us understand this with an example. We can solve this problem in two different ways. Digit by digit sum calculation. Converting a list to the number and calculate the sumRead More »

# Sum of digits of a number using recursion and iterative approaches.

Divide each digit from the input number by using a modulus operator (with 10), and then adding it into a total will give us the sum of its digits. Let us take this solution with an example. This problem can be solved iteratively and recursively. Let us see the code for both approaches. Recursive approachRead More »

# Find the number of occurrences of the given input in a linked list.

We are given a linked list of integers and an integer, which we want to calculate occurrences. We aim to find the count of events of the object in the linked list. To find the count of occurrences, we simply iterate over each item and checks if the current thing is equivalent to the givenRead More »

# Find the number of capital letters in a file

As a first step to solve this problem, we need to have a file descriptor with a read (“r”) mode to read the contents of the file. In this problem, we need to read each character and need to check if that character is in capital letter boundary (i.e., between ‘A’ to ‘Z’). If so,Read More »

# Data types in C Programming

A Data Type in C is a metadata that represents the program data, which also tells the compiler or interpreter about the data. These data types also defines all its proper operations on corresponding data. Every variable that we use in the C Program created with specific data types. Based on the type of dataRead More »

# Arrays in C (definition and initialization)

Array is a data type to store similar types of elements in contiguous memory segments, pictorial representation of arrays is as shown below. Above array of 7 integers represents with variable “a” is {1, 5, 1, 2, 6, 8, 3} starts at address 1000. In a 32bit machine size of an integer value is 4bytesRead More »

# How to find merge point of two linked lists

Let us take two linked lists which at some point merge as one list. Our goal is to find the point where the given two linked lists merging. The most optimized solution for this problem is to find the maximum length list and jump each node until both lists length becomes the same. Below isRead More »

# C Program without main function

Every C program starts with an implicit function _start(), which calls the function main implicitly. If we don’t provide function “main” in the C program, the compiler throws “_main” undefined symbol from entry error. Any program written in C should provide the main function to compile it properly. We can write a hack before preprocessorRead More »

# C program to dynamically allocate two-dimensional memory (arrays)

Allocating dynamic memory using malloc & calloc is a basic functionality of any C program. Whereas allocating a 2D dynamic memory is a complex task to C beginners. Here in this article, we will see how to allocate memory for a two-dimensional integer pointer using malloc. First of all let us write a simple 2×3Read More »

# C program to get the number of lines of a file

One of the fundamental databases for C programming is Files (IO). In this article we are going to count the number of lines in a given file. Function reads the FILE pointer as an input argument and returns the count of lines in the given file pointer. To finish this requirement we are going toRead More »

# how sizeof operator works in C

sizeof operator is one of the most useful C operators to find the size of any operator or variable in bytes. This usually takes the difference between the next and current address of the given variable. To understand this in a better way, let us take a variable array with 5 elements. Now, lets printRead More »

# C program to convert file contents to upper case

Given a file with all types of characters. Our aim here is to convert file contents into their upper case. Let us take below example program file and convert its content to capital letters. Our program should convert this file as shown below. To solve this problem, we need to have a temporary file thatRead More »

# Sort binary array (contain 0s and 1s) in best complexity (O(n))

Given an array of binary (0 or 1) numbers, we aim to sort that binary array in ascending order with minimum possible complexity. Let us take the below example requirement. We can sort these binary elements iteratively. In every iteration we swap left-most “1” with rightmost “0”. This iteration continuous until right most “0” indexRead More »

# Display contents of a file in reverse orders using C

This article demonstrates how to get all characters in a text file in reverse order using the C program. Let us take below the example text input file and expected outputs. Our C program should display the above file in reverse order as shown below. Let’s write the C program to solve the above requirement.Read More »

# Memory layout of a C Program

Before we start learning C programming, it is good to understand how the memory of a C program organizes. Every C program contains five types of memory in it. TEXT/CODE Segment. DATA Segment. UNINITIALIZED DATA (B SS) Segment. HEAP Segment. STACK Segment. These memory segments from top to bottom arranged from low memory to highRead More »