Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double giveMeMaxmum(double theArray[], int size)
- {
- double max = theArray[0];
- for (int i = 1; i < size; i++)
- {
- if (max <= theArray[i])
- {
- max = theArray[i];
- }//endif
- }//endfor
- return max;
- }//end max
- void getData(double &l, double &w)
- {
- cout << "Enter value for length: ";
- cin >> l;
- cout << endl;
- cout << "Enter value for width: ";
- cin >> w;
- }
- void showData(double l, double w)
- {
- cout << "your length is :" << l <<"\n";
- cout << "your width is :" << w <<"\n";
- }
- void getAreaVoid(double l, double w)
- {
- double area = l * w;
- cout << "The area is ";
- cout << area << endl;
- }
- double getAreaReturned(double &l, double &w)
- {
- double area = l * w;
- return area;
- }
- int main()
- {
- //the regular arrays
- const int FIVE = 5;
- double sampleArray[FIVE];
- for (int i = 0; i < FIVE; ++i)
- {
- cout << "Input data for index " << i <<": ";
- cin >> sampleArray[i];
- }//endfor
- double sum = 0;
- double max = sampleArray[0];
- double min = sampleArray[0];
- for (int i = 0; i < FIVE; ++i)
- {
- cout << "data at index " << i << " = " << sampleArray[i] << endl;
- sum = sum + sampleArray[i];
- if (max <= sampleArray[i])
- {
- max = sampleArray[i];
- }
- if (min >= sampleArray[i])
- {
- min = sampleArray[i];
- }
- }//endfor
- cout << "the sum is " << sum << endl;
- cout << "Max is " << max << endl;
- cout << "Min is " << min << endl;
- cout << "the maximum coming from the function is "<< giveMeMaxmum(sampleArray, FIVE) <<endl;
- //the double arrays
- const int row=3;
- const int column=3;
- double sales[row][column];
- for(int i = 0; i < row; ++i)
- {
- for (int j = 0; j < column; ++j)
- {
- cin >> sales[i][j];
- }//endfor
- }//endfor
- for (int i = 0; i < row; ++i)
- {
- for (int j = 0; j < column; ++j)
- {
- cout << sales[i][j];
- }//endfor
- cout << endl;
- }//endfor
- //THE STRUCTS
- struct rectangle
- {
- double length;
- double width;
- };
- rectangle myRectangle;
- getData(myRectangle.length, myRectangle.width );
- showData(myRectangle.length, myRectangle.width);
- getAreaVoid(myRectangle.length, myRectangle.width);
- double len = myRectangle.length;
- double wid = myRectangle.width;
- cout << len << endl;
- cout << wid << endl;
- cout << "The area is " << getAreaReturned(len, wid) << endl;
- //the pointers with arrays
- short numbers[] = { 10, 20, 30, 40, 50 };
- for (int i = 0; i < 5; ++i)
- {
- cout << "The element of my array is:" << *(numbers+i) << endl;
- }
- for (int i = 0; i < 5; ++i)
- {
- cout << "The address is:" << &(numbers[i]) << endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement