1#include <iostream>
2using namespace std;
3
4int main() {
5 int numbers[5] = {7, 5, 6, 12, 35};
6
7 cout << "The numbers are: ";
8
9 // Printing array elements
10 // using range based for loop
11 for (const int &n : numbers) {
12 cout << n << " ";
13 }
14
15
16 cout << "\nThe numbers are: ";
17
18 // Printing array elements
19 // using traditional for loop
20 for (int i = 0; i < 5; ++i) {
21 cout << numbers[i] << " ";
22 }
23
24 return 0;
25}
1#include<iostream>
2
3int main()
4{
5 int array[8] = {1,2,3,4,5,6,7,8};
6 int i = 0;
7
8 while (i <= sizeof(array)/sizeof(int))
9 {
10 std::cout << array[i];
11 i++;
12 }
13}