Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- void multiDimentionArray();
- void EnterToArray();
- void playingWithStrings();
- float calcAverage(int[]);
- void callFunctions();
- int main()
- {
- // multiDimentionArray();
- // EnterToArray();
- // playingWithStrings();
- callFunctions();
- return 0;
- }
- void multiDimentionArray()
- {
- int A[4][3] = {{1, 2, 3},
- {4, 5, 6},
- {7, 8, 9},
- {10, 11, 12}};
- for (int i = 0; i <= 3; i++)
- {
- for (int j = 0; j <= 2; j++)
- {
- std::cout << A[i][j] << std::endl;
- }
- }
- }
- void EnterToArray()
- {
- int mat[3][5], row, col;
- for (row = 0; row < 3; row++)
- {
- for (col = 0; col < 5; col++)
- {
- std::cout << "Enter a digit: ";
- std::cin >> mat[row][col];
- }
- }
- for (int i = 0; i <= row - 1; i++)
- {
- for (int j = 0; j <= col - 1; j++)
- {
- std::cout << mat[i][j] << std::endl;
- }
- }
- }
- void playingWithStrings()
- {
- char str[80];
- std::cout << "Please enter a string: ";
- std::cin.getline(str, 80);
- std::cout << str << std::endl;
- std::puts(str);
- }
- float calcAverage(int a[])
- {
- float average, int sum = 0;
- for (int i = 0; i < 5; i++)
- {
- sum += a[i];
- }
- average = sum / 5;
- return average;
- }
- void callFunctions()
- {
- int A[5];
- for (int i = 0; i < 5; i++)
- {
- std::cout << "Enter a number: ";
- std::cin >> A[i];
- }
- float average = calcAverage(A);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement