English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

give complete program details using c language

2007-03-06 17:34:43 · 6 answers · asked by suro 1 in Computers & Internet Programming & Design

6 answers

PROGRAM ArmstrongNumber
IMPLICIT NONE

INTEGER :: a, b, c ! the three digits
INTEGER :: abc, a3b3c3 ! the number and its cubic sum
INTEGER :: Count ! a counter

Count = 0
DO a = 0, 9 ! for the left most digit
DO b = 0, 9 ! for the middle digit
DO c = 0, 9 ! for the right most digit
abc = a*100 + b*10 + c ! the number
a3b3c3 = a**3 + b**3 + c**3 ! the sum of cubes
IF (abc == a3b3c3) THEN ! if they are equal
Count = Count + 1 ! count and display it
WRITE(*,*) 'Armstrong number ', Count, ': ', abc
END IF
END DO
END DO
END DO

END PROGRAM ArmstrongNumber

2007-03-06 17:38:40 · answer #1 · answered by abd 5 · 0 0

here is the program to print armstrong numbers from 1 to 1000

#include
main()
{
int a,b,c,d;
for(a=1;a<=1000;a++)
{
c=a;
d=0;
while(a!=0)
{
b=a%10;
a=a/10;
d=(b*b*b)+d;
}
a=c;
if(d==c)
printf("\narmstrong number %d\n",c);

}

2007-03-06 17:55:58 · answer #2 · answered by dolly 2 · 0 0

#include

void main()
{
int i=0, a=0,b=0,c=0,sum=0;

for(i=0;i<999;i++)
{
sum=0;
a=i%10; /* Units Digit */
b=(i%100-a)/10; /* Tenths digit */
c=(i%1000-(b*10+a))/100; /*100ths Digit*/
sum= (a*a*a) + (b*b*b) + (c*c*c);
if(i==sum)
printf("Armstong Number: %d\n",sum);
}

}

2007-03-06 19:17:34 · answer #3 · answered by JayCee 1 · 0 0

it truly is a pgm to print unusual form b/w 3 and one thousand no longer best form.best form is a form it truly is divisible by one and the type itself to discover best form do following int isPrime(int num){ static int i=2; if(i<=num/2){ if(nump.c.i==0) go back 0; else{ i++; isPrime(num); } } go back a million; }

2016-10-17 10:49:39 · answer #4 · answered by ? 4 · 0 0

The asker asked for it in C.

Check out this link - it has a version in C

2007-03-06 17:47:58 · answer #5 · answered by BigRez 6 · 0 0

int cube(int n)
{
return n*n*n;
}

main()
{
int i;
for(i=0;i<1000;i++)
{
if ( i == cube(i%10) + cube((i/10)%10) + cube((i/100)%10))
{
printf("%d\n", i);
}
}
}

2007-03-06 20:05:14 · answer #6 · answered by Tom 2 · 0 0

fedest.com, questions and answers