 # C Programming Code Examples

## C > Mathematics Code Examples

### C Program to Check whether a given Number is Armstrong

``` C Program to Check whether a given Number is Armstrong This C Program checks whether a given number is armstrong number. An Armstrong number is an n-digit base b number such that the sum of its (base b) digits raised to the power n is the number itself. 407 = 4^3 + 0^3 + 7^3 = 407. #include <stdio.h> #include <math.h> void main() { int number, sum = 0, rem = 0, cube = 0, temp; printf ("enter a number"); scanf("%d", &number); temp = number; while (number != 0) { rem = number % 10; cube = pow(rem, 3); sum = sum + cube; number = number / 10; } if (sum == temp) printf ("The given no is armstrong no"); else printf ("The given no is not a armstrong no"); } ```

C Evaluating Subtraction of Two Matrices - Before accepting the Elements Check if no of rows and columns of both matrices is equal. Accept the Elements in Matrix 1. Accept the Elements in Matrix 2. Subtraction of two...

Tower Of Hanoi Alogithm Using Recursion - C++ Program to implement "Tower Of Hanoi" alogithm using recursion. Shows Movements of disk from one tower to another when a key is pressed. Entering the fibonacci number and

Count Zeros and Ones in a Binary Number - Program input a number from user and count total number of ones (1s) and zeros (0s) in the given number using bitwise operator. How to count zeros and ones in binary number using

Calculates Area & Circumference of Circle - To calculate area and circumference we must know the radius of circle. C program code will prompt user to enter the radius and based on the input it would calculate the values. Make

Swapping Two Numbers Without Variable - Imagine we have two number 1 and 2 stored in x and j respectively now. If we add x and j (1 + 2) and store it to x then x will become 3 and j is still 2. We subtract j (2) from new value of

C++ Code Calculate Power of any Number - For calculating the power of any number user have four possibilities to input values. Sample code only work for when we input +ve power, +ve 'base value', -ve base value. It is not work

Assignment Operators in The C Language - C Programming to assignment operators. An Assignment Operator is used for assigning a value to a variable. C code demonstrate the working of assignment operators. The most

C Program Insertion Sort implementations - 'Insertion Sort Algorithm' picks elements one by one & places it to the right position where it belongs in the "Sorted List of Elements". In C program we have "implemented the same"