C program to find Number is Armstrong or not. It is a simple source code that provides the output of an actual Armstrong number. Take care of a questions for your interviews or students exam. This is a totally free of cost code.
IND NUMBER IS ARMSTRONG OR NOT IN C
Find the given number is Armstrong or not program in C used to detect the input number is Armstrong or not by calculating and sum the individual cube value of each number. If it is same to the given number then it will display an output. For example, the given number is 153(13+53+33=153) then it will be an Armstrong number.
C CODE:
Q: Write a C program to check whether a given input value is Armstrong number or not.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| //Header files #include <stdio.h> #include <conio.h> #include <math.h> void main() { //Program variables int number,temp,number1,sum=0; clrscr(); //Function to clear previous output printf ( "Enter number : " ); //Display function scanf ( "%d" ,&number); //Getting input function temp=number; //check number is Armstrong are not while (number>0) //Unconditional statement { number1=number%10; sum+= pow (number1,3); number/=10; } if (sum==temp) //Conditional ststement printf ( "Number is armstrong number" ); getch(); } |
No comments:
Post a Comment