Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. void multiDimentionArray();
  5. void EnterToArray();
  6. void playingWithStrings();
  7. float calcAverage(int[]);
  8. void callFunctions();
  9.  
  10. int main()
  11. {
  12. // multiDimentionArray();
  13. // EnterToArray();
  14. // playingWithStrings();
  15. callFunctions();
  16. return 0;
  17. }
  18. void multiDimentionArray()
  19. {
  20. int A[4][3] = {{1, 2, 3},
  21. {4, 5, 6},
  22. {7, 8, 9},
  23. {10, 11, 12}};
  24. for (int i = 0; i <= 3; i++)
  25. {
  26. for (int j = 0; j <= 2; j++)
  27. {
  28. std::cout << A[i][j] << std::endl;
  29. }
  30. }
  31. }
  32. void EnterToArray()
  33. {
  34. int mat[3][5], row, col;
  35. for (row = 0; row < 3; row++)
  36. {
  37. for (col = 0; col < 5; col++)
  38. {
  39. std::cout << "Enter a digit: ";
  40. std::cin >> mat[row][col];
  41. }
  42. }
  43. for (int i = 0; i <= row - 1; i++)
  44. {
  45. for (int j = 0; j <= col - 1; j++)
  46. {
  47.  
  48. std::cout << mat[i][j] << std::endl;
  49. }
  50. }
  51. }
  52. void playingWithStrings()
  53. {
  54. char str[80];
  55. std::cout << "Please enter a string: ";
  56. std::cin.getline(str, 80);
  57. std::cout << str << std::endl;
  58. std::puts(str);
  59. }
  60. float calcAverage(int a[])
  61. {
  62. float average, int sum = 0;
  63. for (int i = 0; i < 5; i++)
  64. {
  65. sum += a[i];
  66. }
  67. average = sum / 5;
  68. return average;
  69. }
  70. void callFunctions()
  71. {
  72. int A[5];
  73. for (int i = 0; i < 5; i++)
  74. {
  75. std::cout << "Enter a number: ";
  76. std::cin >> A[i];
  77. }
  78. float average = calcAverage(A);
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement