Ads

C Program for Sum of Digits and Armstrong Number.

Lets see C program for Sum of digits and Armstrong number. both are same logic with different modification.

⬇️


C Program to Compute the Sum of Digits in a given Integer

This is a C program to compute the sum of digits in a given integer.
Problem Description
This program computes the sum of digits in a given integer.
Problem Solution
1. Take the integer as input.
2. Divide the input integer by 10, obtain its remainder and quotient.
3. Increment the new variable with the remainder got at step 2.
4. Repeat the step 2 & 3 with the quotient obtained until the quotient becomes zero.
5. Print the output and exit.
Output:

C Program to Check whether a given Number is Armstrong

This is a C Program to check whether a given number is Armstrong.
Problem Description
This C Program checks whether a given number is Armstrong number.
Problem Solution
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. Hence 153 because 13 + 53 + 33 = 1 + 125 + 27 = 153.

Output:

Thank you.

Comments

Popular posts from this blog

Datatypes in C

Ethical Hacking V10

Installing Anaconda on Windows.