i want to know what is wrong in this program...why is error showing..?
Attachments:
Answers
Answered by
1
I think there's some problem in the class name. otherwise the program is correct
Answered by
1
U haven't given the data type for sum.
Here is the program for armstrong numbers
class armstrong
{
public static void main(int a)
{
int n=a,sum=0;
while(n>0)
{
int rem=n%10;
int p=(int)(Math.pow(rem,3));
sum+=p;
}
if(a==sum)
System.out.println("Armstrong");
else
System.out.println("Not Armstrong");
}
}
Here is the program for armstrong numbers
class armstrong
{
public static void main(int a)
{
int n=a,sum=0;
while(n>0)
{
int rem=n%10;
int p=(int)(Math.pow(rem,3));
sum+=p;
}
if(a==sum)
System.out.println("Armstrong");
else
System.out.println("Not Armstrong");
}
}
Similar questions