diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..e3ea3d908 Binary files /dev/null and b/.DS_Store differ diff --git a/Dynamic Programming/.DS_Store b/Dynamic Programming/.DS_Store new file mode 100644 index 000000000..0ff1e333a Binary files /dev/null and b/Dynamic Programming/.DS_Store differ diff --git a/Dynamic Programming/Armstrong Number.cpp b/Dynamic Programming/Armstrong Number.cpp new file mode 100644 index 000000000..18d625e1e --- /dev/null +++ b/Dynamic Programming/Armstrong Number.cpp @@ -0,0 +1,20 @@ +//program to check whether a number is an armstrong number or not +#include +#include +int main() +{ + int n,k,d,s=0; + cout<<"Enter a number:"; + cin>>n; + k=n; + while(k!=0) + { + d=k%10; + s+=(int)pow(d,3); + k/=10; + } + if(s==n) + cout< In our code, we have extracted each digit of the number, found its cube and stored the sum of all such cubes in a variable. This sum has been compared in the end with the original number. + +> We have used a function 'pow' to find the cube of each digit. For its implementation, a header file 'Math.h' has been used. diff --git a/Graph/.DS_Store b/Graph/.DS_Store new file mode 100644 index 000000000..92db3084d Binary files /dev/null and b/Graph/.DS_Store differ diff --git a/Greedy Algorithms/.DS_Store b/Greedy Algorithms/.DS_Store new file mode 100644 index 000000000..20f69ade7 Binary files /dev/null and b/Greedy Algorithms/.DS_Store differ