# C Programming Code Examples

## C > Conversions Code Examples

### C Program to Convert Binary to Hexadecimal

``` C Program to Convert Binary to Hexadecimal This program takes a binary number as input and converts to hexadecimal. - Take a binary number as input. - Divide the binary number into groups of 4 bits. For each group of 4 bits, multiply each bit with the power of 2 and add them consecutively. - Combine the result of all groups to get the output. /* C Program to Convert Binary to Hexadecimal */ #include <stdio.h> int main() { long int binaryvalue, hexadecimalvalue = 0, j = 1, remainder; printf("Enter the binary number: "); scanf("%ld", &binaryvalue); while (binaryvalue != 0) { remainder = binaryvalue % 10; hexadecimalvalue = hexadecimalvalue + remainder * j; j = j * 2; binaryvalue = binaryvalue / 10; } printf("Equivalent hexadecimal value: %lX", hexadecimalvalue); return 0; } Take a binary number as input and store it in the variable binaryvalue. Obtain the remainder and quotient of the input number by dividing it by 10. Multiply the obtained remainder with variable j and increment the variable hexadecimalvalue with this value. Increment the variable j by 2 and override the variable binaryvalue with the quotient obtained. Repeat the steps 2-4 until the variable binaryvalue becomes zero. Print the variable hexadecimalvalue as output. ```

C code All types of Linked List Operations - This is a Program About Linked List. Supply no. of elements in the linked list. Node you want to add before. Node you want to add end. Before which node you want to add?...

Find Maximum Minimum using Functions - First give a meaningful name to our function. Say max() function is used to find maximum between two numbers. Second, we need to find maximum between two numbers. And

Print Perfect numbers between an interval - Declare function to print all Perfect Numbers in given range. First give meaningful name to the function. Say "printPerfect()" will print all perfect numbers in given range. Along with...

Multiline Comments in C++ programming - To write a "Multiline Comment" you have to write "/*" at the start of the Comment. After this you can write as many number of lines of description. When you are done with writing

Fibonacci Series in C Language using Loop - C Program for Loop to display the Fibonacci series. Program prompts user for the number of terms and displays the series having the same number of terms. Program ask user to

Generate Random Subset by Coin Flipping - Prints a 'subset' of the given array using coin flipping method. The time complexity of this algorithm is O(n). Takes the input of 'n' data element and prints a possible subset. that, it

C Program Convert Binary to Hexadecimal - C Language program takes a binary number as input and converts to hexadecimal. Take a binary number as input. And divide the binary number into groups of 4 bits. For each group

Check Prime or Armstrong Number Using - In this program, two User-Defined functions checkPrimeNum() & checkArmstrongNum() are created. The checkPrimeNum() returns 1 if the number entered by the user is a Prime