C : Program to check given number is armstrong or not.
Code:
#include<stdio.h>
#include<conio.h>
main()
{
int n,x;
printf("Enter a number:");
scanf("%d",&n);
x=armstrong(n);
if(x==n)
printf("Arm strong");
else
printf("Not arm strong");
}
int armstrong(int num)
{
int sum=0,r;
while(num!=0)
{
r=num%10;
num=num/10;
sum=sum+(r*r*r);
}
return sum;
}
Output:
Enter a number:1
Arm strong
Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...
-
Character I/O: Visual Basic provides some excellent ways for input and output operations. Input can be taken using TextBox, InputBox, ...
-
Design a form contains a sorted list alphabetically such that the user can add the item from text to the list after click on command button...
-
Scientific Calculator Created Using Visual Basic This is a calculator that resembles a typical scientific calculator , albeit a simpler ...