I am stuck on 2 and 3

Exercise #1:
Write a program that declares a two-dimensional array named myFancyArray of the type
double. Initialize the array to the following values:
23 14.12 17 85.99
6.06 13 1100 0
36.36 90.09 3.145 5.4
1. Create a function that will return the sum of the third column. Output this result.
2. Create a function that finds the ceiling [the closest whole number that is not smaller
than that number. So ceil(4.6) is 5 and ceil(4.2) is 5, and ceil(-3.4) is -3
]of each value in the array.
3. Create a function that will use a nested loop to display all the elements in the array to
the screen.
This is what I have so far

#include <iostream>
#include<fstream>
using namespace std;
int main()
{
double myFancyArray[3][4];
myFancyArray[0][0] = 23; myFancyArray[0][1] = 14.12; myFancyArray[0][2] = 17; myFancyArray[0][3] = 85.99;
myFancyArray[1][0] = 6.06; myFancyArray[1][1] = 13; myFancyArray[1][2] = 1100; myFancyArray[1][3] = 0;
myFancyArray[2][0] = 36.36; myFancyArray[2][1] = 90.09; myFancyArray[2][2] = 3.145; myFancyArray[2][3] = 5.4;
cout << "The total of column 3 is " << myFancyArray[0][2] + myFancyArray[1][2] + myFancyArray[2][2] << endl;// the total in column 3 is 1120.15
}
#2 might look something like this (warning, I did not debug, test, or anything... this is off the cuff and may need to be cleaned up).

1
2
3
4
5
6
7
long long myceil(double d)
{
    long long i = d; //let automatic casting do the work for you
    if(d <= 0)  
        return i; //handles 0 and negative values
    return i+1;    //positive values
}


you would call that on each value in the array in a loop, of course. you can modify the above to do that or write a second function that uses this one. if allowed, there is a built in ceil() function already, but it sounds like they want you to reinvent it.

#3 should be easy now, try it.
Last edited on
Registered users can post here. Sign in or register to post.
<blockquote id="pwjBlLZ"><tr id="pwjBlLZ"></tr></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect><blockquote id="pwjBlLZ"><option id="pwjBlLZ"></option></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"></option></delect>
<delect id="pwjBlLZ"><option id="pwjBlLZ"></option></delect>
<delect id="pwjBlLZ"></delect>
<mark id="pwjBlLZ"></mark>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
<nav id="pwjBlLZ"><tr id="pwjBlLZ"><address id="pwjBlLZ"></address></tr></nav>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"></delect>
<mark id="pwjBlLZ"><tr id="pwjBlLZ"></tr></mark>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<blockquote id="pwjBlLZ"><option id="pwjBlLZ"></option></blockquote>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
  • 629832435 2018-04-20
  • 4254782434 2018-04-20
  • 7642392433 2018-04-20
  • 4201592432 2018-04-20
  • 1221362431 2018-04-20
  • 5455692430 2018-04-20
  • 8345962429 2018-04-20
  • 7297372428 2018-04-20
  • 4929522427 2018-04-20
  • 1938132426 2018-04-20
  • 2267862425 2018-04-20
  • 6177082424 2018-04-20
  • 838232423 2018-04-20
  • 4694502422 2018-04-20
  • 6512882421 2018-04-19
  • 4659652420 2018-04-19
  • 2967832419 2018-04-19
  • 8339042418 2018-04-19
  • 8147112417 2018-04-19
  • 2774752416 2018-04-19