Arrays and Scope of Variables in C++ date: -- 19/08/2026

 // Online C++ compiler to run C++ program online

#include <iostream>

using namespace std;



void counter(){

    static int a=0;

    a++;

    cout<<a<<endl;

}


int main() {

    // Write C++ code here

    // int arr[]={3,23,4,55,23};

    // cout<<arr[0]<<endl;

    // for(int i=0;i<5;i++){

    //     cout<<arr[i]<<endl;

    // }

    int matrix[2][3]={

        {2,3,4},

        {7,8,91}

    };

    // for(int i=0;i<2;i++){

    //     for(int j=0;j<3;j++){

    //         cout<<matrix[i][j]<<" ";

    //     }

    //     cout<<endl;

    // }

    // int arr[5] = {10, 20, 30, 40, 50};

    // int *ptr=arr;

    // *(ptr+4)=123;

    // for(int i=0;i<5;i++){

    //     cout<<*(ptr+i)<<endl;

    // }

    int (*ptr)[3]=matrix;

    for(int i=0;i<2;i++){

        for(int j=0;j<3;j++){

            cout<<*(*(ptr+i)+j)<<endl;

        }

    }

    auto a=12.34;

    cout<<a<<endl;

    counter();

    counter();

    counter();


    return 0;

}

Comments

Popular posts from this blog

Requests and Urllib

Strings in C Language

Dictionary in Python