Advertisement
35657

Untitled

Mar 15th, 2024
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template<typename T>
  6. void display(T arr[], int size) {
  7.     for (int i = 0; i < size; i++) {
  8.         cout << arr[i] << " ";
  9.     }
  10.     cout << endl;
  11. }
  12.  
  13. int main() {
  14.     int arr[]{ 1, 3, 7, -4, -2, 4 };
  15.     int size = 6;
  16.     display(arr, size);
  17.  
  18.     double arr2[]{ 3.5, 2.5, 3.7, 1.0, 3.3, 7.2 };
  19.     display(arr2, size);
  20.  
  21.     char arr3[]{ 'a', 'b', 'c', 'd', 'e', 'f'};
  22.     display(arr3, size);
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement