+ 2

Program to find sum of n number using constructor.

19th May 2017, 3:51 AM
Yysh Ag
Yysh Ag - avatar
9 Answers
+ 1
using function or class?
19th May 2017, 3:56 AM
Rohit Singh Rawat
Rohit Singh Rawat - avatar
+ 1
what type of answer you want?
19th May 2017, 3:56 AM
Rohit Singh Rawat
Rohit Singh Rawat - avatar
+ 1
wait
19th May 2017, 4:03 AM
Rohit Singh Rawat
Rohit Singh Rawat - avatar
0
using function
19th May 2017, 4:01 AM
Yysh Ag
Yysh Ag - avatar
0
long sum(int n, int a[]) { long sum; for(int i=0; i<n; i++) { sum+=a[i]; } return sum; }
19th May 2017, 4:07 AM
Rohit Singh Rawat
Rohit Singh Rawat - avatar
0
do all
19th May 2017, 4:08 AM
Yysh Ag
Yysh Ag - avatar
0
??
19th May 2017, 4:08 AM
Rohit Singh Rawat
Rohit Singh Rawat - avatar
0
do all program
19th May 2017, 4:09 AM
Yysh Ag
Yysh Ag - avatar
0
#include <iostream> using namespace std; int main() { int n, arr[50]; cout<<"Enter the no of Numbers: "; cin>>n; cout<<"Enter the numbers: "; for(int i=0; i<n; i++) { cin>>arr[i]; } sum(n, arr); return 0; }
19th May 2017, 4:18 AM
Rohit Singh Rawat
Rohit Singh Rawat - avatar