Publicidad

Add a function prototype for the function sumNum- # include using nam.docx

wviola
3 de Feb de 2023
Add a function prototype for the function sumNum- # include  using nam.docx
Add a function prototype for the function sumNum- # include  using nam.docx
Próximo SlideShare
UNIT3.pptxUNIT3.pptx
Cargando en ... 3
1 de 2
Publicidad

Más contenido relacionado

Más de wviola(20)

Publicidad

Add a function prototype for the function sumNum- # include using nam.docx

  1. Add a function prototype for the function sumNum. # include using namespace sted; int main (void) { float val; float amount; int n; cin >> val >> n; sumNum (amount, val, n); cout Solution Prototype of function : In function concept prototype declaration is necessary in order to provide information to the compiler about function, about return type, parameter list and function name etc. Program : # include<iostream .h > using namespace std; float sumNum(float,float, int); /* prototype for the function sumNum it accept the sum value which is a float value and parameter list mentioned, i.e. float,float, int */ int main (void) //main function float amount; int n; cin>>val>>n; // Accept the value sumNum(amount,val,n); // Calling function cout<<amount<<end1; } void sumNum(float &sum, float x,int n); // Called function
  2. { int i; sum=0.0; //Intilise the sum value to zero. for(i=1;i<=n;i++) { sum=sum+i*x; // calculate the sum } return sum; // Here we return sum value }
Publicidad