Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lab 6 mb
//gcc 5.4.0 //int n; Example //int d; //READ n n=153 //int nn=n; nn=153 //int sum=0; sum=0 //WHILE (n>0){ when n is greater than 0 run loop // d=n%10; find remainder of n 1.3 2.5 3.1 // sum+=(d*d*d); find cube of remainders 1.9 2.125 3.1 and add them to sum=153 // n=n/10; divide n by 10 to remove cycle through place values //} //if n=sum set of if statements if nn(the original input)=sum the entered value is an armsrong number the program prints that it is // PRINT nn is an armstrong number if the sum doesn't equal the original input the program prints that the number wast an armstrong number. //if n!=sum // PRINT nn is not an armstrong number #include <stdio.h> int main(void) { int n; int d; scanf("%d",&n); int nn=n; int sum=0; //printf("%d\n",nn); while(n>0){ d=n%10; sum+=(d*d*d); n=n/10; } // printf("%d\n",nn); if(nn==sum) printf("%d is an armstrong number!",nn); if(nn!=sum) printf("%d isn't an armstrong number :(",nn); }
run
|
edit
|
history
|
help
0
Project 4 v0.1
3468
SumIt
bitwise operations
arrays vowles printing
print name
Access the structure variable
QuestResp
Tern operators
Quadratic Formula