Logo 
Search:

C Programming Forum

Ask Question   UnAnswered
Home » Forum » C Programming       RSS Feeds

Need help with my source code.

  Asked By: Agustin    Date: Oct 30    Category: C Programming    Views: 2255
  

I need to create a program to read an array of doubles from the keyboard, calculate the sum, and print the array and its sum. In main(), declare a double array that can hold up
to 50 doubles and an integer to store the current size (initialize this to 0). Then call the getInput() and
printArray() functions.

This is the pseudo code.

How many doubles do you wish to add? -5
That is an invalid size. You must enter a value between 1 and 50.
How many doubles do you wish to add? 5
Enter double 1: 1
Enter double 2: 1.5
Enter double 3: 2
Enter double 4: 3.2
Enter double 5: 2.5
The array contains:
1.00 1.50 2.00 3.20 2.50
The sum is 10.2

Here is what i have so far. I am missing a lot. Any help will be appreciated.

#include <iostream>
using namespace std;

void getInput( double[], int& );
void printArray(double[], int& );

int main()
{
const int array_size = 50;
double arr[array_size] = 0;
int length;

return 0;
}

void getInput( double num[], int& n )
{
cout << "How many doubles do you wish to add?"
cin >> n;

for(int length; i <= n; i++)
{
cin >> n;
}

}

void printArray( double num[], int& n )
{

}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Need help with my source code. Or get search suggestion and latest updates.




Tagged: