3IIR – C++ 24/25
/*
Arrays
- What Is Array ?
--- Collection Of Elements Of The Same Type
--- Placed in Contiguous Memory Locations
--- Referenced By Index Started From 0
- Why We Need Array ?
- Creating Array Syntax
- Check Array Size
- Create Array Without Size
Loop
- Loop With For
- Loop On Array
Syntax
for(init, Condition, Update)
// Block Of Code
*/
#include <iostream>
using namespace std;
int main(){
int nums[4] = {100, 200, 300, 400}; // it is possible to leave out the “=” sign – But it is a good
practice to put it.
cout << sizeof(int) << "\n"; // 4 Bytes
cout << sizeof(nums) << "\n"; // 16 Bytes
cout << “Array Elements Count” << sizeof(nums) / sizeof(nums[0]) << "\n"; // Array Elements Count
Pr. Hasnââ CHAABI
3IIR – C++ 24/25
cout << "First Element: " << nums[0] << "\n"; // Prints the first element
cout << "Location: " << &nums[0] << "\n"; // Print the address
double dos[4] = {100, 200, 300, 400};
for (int index = 0; index < 4; index++)
cout << dos[index] << "\n";
while (i < 4) {
cout << dos[i] << "\n";
i++;
int rands[]{100, 5000, 950}; // it is possible to leave out the “=” sign
return 0;}
Pr. Hasnââ CHAABI