Tag Archives: C example

C Example for Beginners: C Program to Convert Binary Number to Octal and vice-versa

(C programming Example for Beginners) C Program to Convert Binary Number to Octal and vice-versa In this example, you will learn to convert binary numbers to octal and vice versa manually by creating a user-defined function. Program to Convert Binary to Octal In this program, we will first convert a binary number to decimal. Then, …

C Example for Beginners: C Program to Convert Octal Number to Decimal and vice-versa

(C programming Example for Beginners) C Program to Convert Octal Number to Decimal and vice-versa In this example, you will learn to convert octal numbers to decimal and vice-versa manually by creating a user-defined function. Example 1: Program to Convert Decimal to Octal #include <stdio.h> #include <math.h> int convertDecimalToOctal(int decimalNumber); int main(){ int decimalNumber; printf(“Enter …

C Example for Beginners: C Program to Convert Binary Number to Decimal and vice-versa

(C programming Example for Beginners) C Program to Convert Binary Number to Decimal and vice-versa In this example, you will learn to convert binary numbers to decimal and vice-versa manually by creating a user-defined function. Program to convert binary to decimal #include <math.h> #include <stdio.h> int convert(long long n); int main(){ long long n; printf(“Enter …

C Example for Beginners: C Program to Find G.C.D Using Recursion

(C programming Example for Beginners) C Program to Find G.C.D Using Recursion In this example, you will learn to find the GCD (Greatest Common Divisor) of two positive integers entered by the user using recursion. This program takes two positive integers as input from the user and calculates GCD using recursion.   GCD of Two …

C Example for Beginners: C Program to Find Factorial of a Number Using Recursion

(C programming Example for Beginners) C Program to Find Factorial of a Number Using Recursion In this example, you will learn to find the factorial of a non-negative integer entered by the user using recursion. The factorial of a positive number n is given by: factorial of n (n!)= 1 * 2 * 3 * 4 *… …

C Example for Beginners: C Program to Find the Sum of Natural Numbers using Recursion

(C programming Example for Beginners) C Program to Find the Sum of Natural Numbers using Recursion In this example, you will learn to find the sum of natural numbers using a recursive function. The positive numbers 1, 2, 3… are known as natural numbers. The program below takes a positive integer from the user and …

C Example for Beginners: C Program to Check Prime or Armstrong Number Using User-defined Function

(C programming Example for Beginners) C Program to Check Prime or Armstrong Number Using User-defined Function In this example, you will learn to check whether an integer is a prime number or an Armstrong or both by creating two separate functions. In this program, two user-defined functions checkPrimeNumber() and checkArmstrongNumber() are created. The checkPrimeNumber() function returns 1 if the number entered by the …

C Example for Beginners: C Program to Make a Simple Calculator Using switch…case

(C programming Example for Beginners) C Program to Make a Simple Calculator Using switch…case In this example, you will learn to create a simple calculator in C programming using the switch statement. This program takes an arithmetic operator +, -, *, / and two operands from the user. Then, it performs the calculation on the two operands …