-
Notifications
You must be signed in to change notification settings - Fork 3
/
series.cpp
47 lines (30 loc) · 827 Bytes
/
series.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//Printing
#include <iostream>
using namespace std;
int main(){
int n , p = 0 , q = 1 ;
float sum = 0;
char opr = '+';
cout<<"Number you want series till : \n";
cin>>n;
while(n>0)
{
for(int i = 1 ; i <= n ; i++)
{
p = i;
q =+ q*i;
if(i == n)
{
cout<<p<<"/"<<q<<" = "<<sum+(float(p)/float(q))<<"\n\n";
return 0;
}
else
{
cout<<p<<"/"<<q<<" + ";
sum += float(p)/float(q);
}
}
}
cout<<"Invalid input please put positive number greater than zero ..Thank you\n\n";
return 0;
}