This blog is under construction

Tuesday, 7 January 2014

Multidimensional arrays in C

Multidimensional array is also known as array of arrays.  C allows user to write arrays with one or more dimensions.  An array with more than one dimension is a multi-dimensional array.  Two dimensional array is a simplest form of multidimensional array.  Below is the general form of multidimensional array.

data_type  array_name[size1][size2][size3]..[sizeN];

Consider the following example
int arr[2][2][2] = {   { {1, 1}, {1, 1} },
                                  { {1, 1}, {1, 1} }
                              };
 
The above statement shows the declaration and initialization of multidimensional array(3d array).  Total number of elements in an array can be obtained by multiplying the size value in each dimension.

int arr[2][2][2];
2 X 2 X 2 = 8 elements in the array arr

And multidimensional array can be accessed using its array indices.
arr[0][0][1] = 2;

The above statement assigns 2 to arr[0][0][1].  Then the resultant value of the array arr would be the following.

     { {1, 2}, {1, 1} },
     { {1, 1}, {1, 1} }
};


Example C program using multidimensional arrays:
#include <stdio.h> 
  int main() {
        int i, j, k, three_dim[2][2][2] = {  // array initialization
                                {{1, 1}, {1, 1}},
                                {{1, 1}, {1, 1}}
                              };

        // printing elements of the array
        printf("Elements of the array three_dim:\n");
        for (i = 0; i < 2; i++)
                for (j = 0; j < 2; j++)
                        for (k = 0; k < 2; k++)
                                printf("three_dim[%d][%d][%d]: %d\n",
                                        i, j, k, three_dim[i][j][k]);

        printf("\nAssign 2 to three_dim[0][0][1]\n");
        three_dim[0][0][1] = 2;  // modifying an array element

        // printing elements of the array
        printf("\nElements of the array after modification:\n");
        for (i = 0; i < 2; i++)
                for (j = 0; j < 2; j++)
                        for (k = 0; k < 2; k++)
                                printf("three_dim[%d][%d][%d]: %d\n",
                                                i, j, k, three_dim[i][j][k]);
        return 0;
  }

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Elements of the array three_dim:
  three_dim[0][0][0]: 1
  three_dim[0][0][1]: 1
  three_dim[0][1][0]: 1
  three_dim[0][1][1]: 1
  three_dim[1][0][0]: 1
  three_dim[1][0][1]: 1
  three_dim[1][1][0]: 1
  three_dim[1][1][1]: 1

  Assign 2 to three_dim[0][0][1]

  Elements of the array after modification:
  three_dim[0][0][0]: 1
  three_dim[0][0][1]: 2
  three_dim[0][1][0]: 1
  three_dim[0][1][1]: 1
  three_dim[1][0][0]: 1
  three_dim[1][0][1]: 1
  three_dim[1][1][0]: 1
  three_dim[1][1][1]: 1



4 comments:

  1. Hello Everyone !

    USA SSN Leads/Dead Fullz available, along with Driving License/ID Number with good connectivity.

    All SSN's are Tested & Verified.

    **DETAILS IN LEADS/FULLZ**

    ->FULL NAME
    ->SSN
    ->DATE OF BIRTH
    ->DRIVING LICENSE NUMBER
    ->ADDRESS WITH ZIP
    ->PHONE NUMBER, EMAIL
    ->EMPLOYEE DETAILS

    *Price for SSN lead $2
    *You can ask for sample before any deal
    *If you buy in bulk, will give you discount
    *Sampling is just for serious buyers

    ->Hope for the long term business
    ->You can buy for your specific states too

    **Contact 24/7**

    Whatsapp > +923172721122

    Email > leads.sellers1212@gmail.com

    Telegram > @leadsupplier

    ICQ > 752822040

    ReplyDelete
  2. Dell Laptop Service center are giving repair service at the door. We should high quality Dell out of warranty Laptop Repair, removal of virus, screen removal, wireless network set up, battery removal, motherboard replacement to several other are offered at budget friendly price and it’s Negotiable. We can fix them all in time by our well experience and certified technicians. If you want to repair your laptop in front of your eyesight, than you may call us: 7217871051

    ReplyDelete
  3. **SELLING SSN+DOB FULLZ**

    CONTACT 24/7
    Telegram > @leadsupplier
    ICQ > 752822040
    Email > leads.sellers1212@gmail.com

    >>1$ each without DL/ID number
    >>2$ each with DL
    >>5$ each for premium (also included relative info)

    Price will be reduce in Bulk order

    FORMAT OF LEADS/FULLZ/PROS

    ->FULL NAME
    ->SSN
    ->DATE OF BIRTH
    ->DRIVING LICENSE NUMBER WITH EXPIRY DATE
    ->COMPLETE ADDRESS
    ->PHONE NUMBER, EMAIL, I.P ADDRESS
    ->EMPLOYMENT DETAILS
    ->REALTIONSHIP DETAILS
    ->MORTGAGE INFO
    ->BANK ACCOUNT DETAILS

    >All Leads are Spammed & Verified.
    >Fresh spammed data of USA Credit Bureau
    >Good credit Scores, 700 minimum scores
    >Invalid info found, will be replaced.
    >Payment mode BTC, ETH, LTC, PayPal, USDT & PERFECT MONEY

    ''OTHER GADGETS PROVIDING''

    >SSN+DOB Fullz
    >CC with CVV
    >Photo ID's
    >Dead Fullz
    >Carding Tutorials
    >Hacking Tutorials
    >SMTP Linux Root
    >DUMPS with pins track 1 and 2
    >Sock Tools
    >Server I.P's
    >HQ Emails with passwords

    Contact 24/7

    Email > leads.sellers1212@gmail.com
    Telegram > @leadsupplier
    ICQ > 752822040

    ReplyDelete
  4. LEGIT FULLZ & TOOLS STORE

    Hello to All !

    We are offering all types of tools & Fullz on discounted price.
    If you are in search of anything regarding fullz, tools, tutorials, Hack Pack, etc
    Feel Free to contact

    ***CONTACT 24/7***
    **Telegram > @leadsupplier
    **ICQ > 752822040
    **Skype > Peeterhacks
    **Wicker me > peeterhacks

    "SSN LEADS/FULLZ AVAILABLE"
    "TOOLS & TUTORIALS AVAILABLE FOR HACKING, SPAMMING,
    CARDING, CASHOUT, CLONING, SCRIPTING ETC"

    **************************************
    "Fresh Spammed SSN Fullz info included"
    >>SSN FULLZ with complete info
    >>CC With CVV (vbv & non vbv) Fullz USA
    >>FULLZ FOR SBA, PUA & TAX RETURN FILLING
    >>USA I.D Photos Front & Back
    >>High Credit Score fullz (700+ Scores)
    >>DL number, Employee Details, Bank Details Included
    >>Complete Premium Info with Relative Info

    ***************************************
    COMPLETE GUIDE FOR TUTORIALS & TOOLS

    "SPAMMING" "HACKING" "CARDING" "CASH OUT"
    "KALI LINUX" "BLOCKCHAIN BLUE PRINTS" "SCRIPTING"
    "FRAUD BIBLE"

    "TOOLS & TUTORIALS LIST"
    =>Ethical Hacking Ebooks, Tools & Tutorials
    =>Bitcoin Hacking
    =>Kali Linux
    =>Fraud Bible
    =>RAT
    =>Keylogger & Keystroke Logger
    =>WhatsApp Hacking & Hacked Version of WhatsApp
    =>Facebook & Google Hacking
    =>Bitcoin Flasher
    =>SQL Injector
    =>Premium Logs (PayPal/Amazon/Coinbase/Netflix/FedEx/Banks)
    =>Bitcoin Cracker
    =>SMTP Linux Root
    =>Shell Scripting
    =>DUMPS with pins track 1 and 2 with & without pin
    =>SMTP's, Safe Socks, Rdp's brute
    =>PHP mailer
    =>SMS Sender & Email Blaster
    =>Cpanel
    =>Server I.P's & Proxies
    =>Viruses & VPN's
    =>HQ Email Combo (Gmail, Yahoo, Hotmail, MSN, AOL, etc.)

    *Serious buyers will always welcome
    *Price will be reduce in bulk order
    *Discount offers will give to serious buyers
    *Hope we do a great business together

    ===>Contact 24/7<===
    ==>Telegram > @leadsupplier
    ==>ICQ > 752822040
    ==>Skype > Peeterhacks
    ==>Wicker me > peeterhacks

    ReplyDelete