FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-programming/OOP1-Lab5/Source3.cpp at main · whshi574/cpp-programming · GitHub
whshi574
/
cpp-programming
Public
forked from
Rustam-Z/cpp-programming
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-programming
/
OOP1-Lab5
/
Source3.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (29 loc) · 963 Bytes
Breadcrumbs
cpp-programming
/
OOP1-Lab5
/
Source3.cpp
Copy path
File metadata and controls
32 lines (29 loc) · 963 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
Practical Lab Assignment-7(Week 9)
//
ID:U1910049 Name: Rustam Zokirov
//
Program to sum the series up to n
#
include
<
iostream
>
#
include
<
math.h
>
using
namespace
std
;
double
qwerty
(
double
n,
double
sum,
double
fact)
{
for
(
int
i =
1
; i <= n; i++)
{
fact = fact * i;
//
calculating the factorial of the numbers
sum += (
pow
(i, i) / (fact));
//
executing the sum of numbers
}
//
"pow" is raising 'i' to power 'i'
return
sum;
//
}
//
end function qwerty
int
main
()
{
double
n;
double
sum =
0
;
double
fact =
1
;
cout <<
"
Please ebter the number:
"
;
//
outputing and inputing the number
cin >> n;
if
(n >
0
)
//
the program will calculate the sum when numbers is positive
cout <<
"
Sum is:
"
<<
qwerty
(n, sum, fact) << endl;
//
calling the function qwerty
else
//
when the number is negative 'else' will work
cout <<
"
INVALID INPUT!
"
<< endl;
system
(
"
pause
"
);
return
0
;
}
//
ending the program successfully
Back
|
FazBrowse Home
|
New Git URL