Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- void main()
- {
- int num, bnum, i, j, count, sum, rem, power;
- printf("This is a simple program to check Armstrong Number.\n\n");
- printf("Enter The number to check : ");
- scanf("%d",&num);
- bnum = num;
- count = 0;
- while (bnum != 0)
- {
- count++;
- bnum = bnum / 10;
- }
- sum = 0;
- bnum = num;
- for(i = 1; i <= count; i++)
- {
- rem = bnum % 10;
- power = 1;
- for(j = 1; j <= count; j++)
- {
- power = power * rem;
- }
- sum = sum + power;
- bnum = bnum / 10;
- }
- if(sum == num)
- {
- printf("%d - is a Armstrong Number.", num);
- }
- else
- {
- printf("%d - is not a Armstrong Number.", num);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement