C Program to Check a Bit of an Integer

An integer consists of 32 bits. Here we’ll see how to write C program to check whether a particular bit is 0 or 1. The above diagram shows the binary representation of an integer 8,55,119. Bit position will start from 0. That means the least significant bit position is 0 and the most significant bit … Continue reading “C Program to Check a Bit of an Integer”

Change a Pointer from inside a C Function

We can change normal variable from inside a C function by passing the pointer of the variable. Here we’ll see how to change a pointer variable from inside a C function. Concept is same, here we have to pass the pointer of the pointer to the function. Code Snippet Here is the output. In main(), … Continue reading “Change a Pointer from inside a C Function”

Change a Variable from inside a C Function

Variables are meant to be changed. But changing a variable from inside a function is a tricky one in C-like programming. Let’s consider this code snippet. Here we started with a variable, x, of 5 and tried to change that from inside the function change_value() by adding 100 with it. The expectation is that the … Continue reading “Change a Variable from inside a C Function”

C Program to Merge Two Sorted Arrays into one Sorted Array

Here we’ll write a C function to merge two sorted arrays into one. The merged array will also be sorted. Here we’ll use two sorted integer arrays that are sorted in ascending order. After merging the result array will contain all the numbers from the original arrays and will be sorted in ascending order. The … Continue reading “C Program to Merge Two Sorted Arrays into one Sorted Array”

C Program to Find the Sum of all Digits of a Number

Here we’ll see how to write a C program to find the summation of all digits in a number. For example, the sum of the digits of 43652 is 20 (4+3+6+5+2) The sum_digits() function returns sum of all digits of the input number n. It has a loop. In every iteration it gets the last … Continue reading “C Program to Find the Sum of all Digits of a Number”

0
0
0
1
0
1