Answer to Question #37765 in C++ for Dil

Question #37765
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; }
Expert's answer

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
16.12.13, 11:35

You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

Dils
14.12.13, 08:10

Didnt know it was this straight forward. Thank you!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal