Skip to content

Commit 7d38d30

Browse files
Preeti amuryasunilkumarmaurya786693
authored andcommitted
added armstrong and fibonacci program
1 parent a244d82 commit 7d38d30

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

basics/armstrong.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int num , original, rem,result=0;
7+
cout<<"enter the three digit number";
8+
cin>>num;
9+
original=num;
10+
whlie(original!=0){
11+
//remender contain last digit
12+
rem=original%10;
13+
result += rem*rem*rem*rem;
14+
15+
// removing last digit from the original number
16+
original=original/10;
17+
}
18+
if(result==num)
19+
cout<<num<<"it is an Armstrong number";
20+
else
21+
cout<<num<<"it is not armstrong number";
22+
23+
return 0;
24+
}

basics/fibonacci.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int first=0,second=1,sum=0,n;
7+
cout<<"Enter the end term for the series";
8+
cin>>n;
9+
cout<<"fibonacci series :"<<first<<""<<second;
10+
11+
sum=first+second;
12+
while(sum<=n){
13+
cout<<sum<<"";
14+
first=second;
15+
second=sum;
16+
sum=first+second;
17+
}
18+
return 0;
19+
}

0 commit comments

Comments
 (0)