Write a function that, using default arguments, allows user to take the sum of anywhere between 2 and 4 integers. This is what i got so far....#include <cstdlib>
#include <iostream>
using namespace std;
void sum(float a,float b);
void sum(int a,int b, int c = 0);
double sum(double a, double b, double c, double d);
int main(int argc, char *argv[])
{
int no[4];
cout<< "Enter any number from 2 to 4: "<<endl;
//Loop until EOF
for(int i=0; no[i]-1 != EOF; i++){
cout<< ">> ";
cin>> no[i]; //Ask value array no[]
i++;
}
sum(no[0],no[1],no[2],no[3]); //call function
system("PAUSE");
return EXIT_SUCCESS;
}
//FUNCTION
int sum(int a, int b){
return a + b;
}
float sum(float a, float b, float c){
return a + b + c;
}
double sum(double a, double b, double c, double d){
return a + b + c + d;
}
The answer to the question is available in the PDF file https://assignmentexpert.com/https://assignmentexpert.com/homework-answers/programming-answer-37765.pdf
Comments
You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!
Didnt know it was this straight forward. Thank you!
Leave a comment