Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PointSum
//g++ 7.4.0 // write a function that returns the sum of the floats pointed to by the first n pointers in the array p //this code is created by Rezaul Hoque on July 27,2021;contact: jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> using namespace std; int n=7; float sum(float * ,int); float sum(float *p[] ,int n){ float sum= 0.0; for (int i=0;i<n;i++) sum += *p[i]; return sum; } int main(){ float a[7]={10.0,20.0,11.0,4.0,5.0,3.0,2.0}; for (int i=0;i<n;i++) cout<<" "<<*(a+i); cout<<"\n"; float * p[7]; for (int i=0;i<n;i++) p[i]=&a[i]; cout<<"The sum is "<<sum(p,7); return 0; }
run
|
edit
|
history
|
help
0
Perf measurement
most Frequent word
12535
Metodos mejorado
IviewwithSelf
new
10 wizards
Sort an array of 0s, 1s and 2s
test
Extended Euclidean Algorithm