Guest User

Untitled

a guest
Apr 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <iomanip>
  11.  
  12. using namespace std;
  13.  
  14. float subtotal (float[], int);
  15.  
  16. int main() {
  17. int arraySize;
  18.  
  19. cout << "Enter array size: ";
  20. cin >> arraySize;
  21.  
  22. float array[arraySize];
  23.  
  24. cout << "Enter an array size of " << arraySize << " : ";
  25. for (int i=0; i<arraySize; i++){
  26. cin >> array[i];
  27. }
  28.  
  29. for (int i=0; i<arraySize; i++){
  30. array [i] = subtotal (array[i], arraySize);
  31. cout <<left<<setw(5)<< array [i];
  32. }
  33.  
  34. return 0;
  35. }
  36.  
  37. float subtotal (float array, int arraySize){
  38. float x = array+5;
  39. return x;
  40. }
  41.  
  42. main.cpp: In function 'int main()':
  43. main.cpp:30:49: error: cannot convert 'float' to 'float*' for argument '1' to 'float subtotal(float*, int)'
  44. array [i] = subtotal (array[i], arraySize);
  45. ^
Add Comment
Please, Sign In to add comment