BMR AI
By using this service you agree to read and accept our Terms and conditions and Privacy Policy
Chat Now
GUIDE

Welcome to our BMR AI CHATBOT.

A free expermental AI tool where you can interact with the webpage, ask question about the webpage and other related doubts.

In some cases reponses may take time to get. In case of error give us your report.

You responses are stored for experimental purpuses. And your personal info is not integrated with you in any way.

Note: AI can make mistakes and can give in appropiate responses. Your feedbak will help us improve.

Stay tuned for more AI products and tools

And Finally don't forget to give your feedback. click on the icon provided to give feedback.

REPORT ERROR

SUBMIT
DELETE CHAT

C Array

Used to store multiple elements of the same data type under a single identifier.
They can be accessed using an index that starts from 0

Syntax:
data_type array_name[size];

  1. data_type - Declaring the type of data in an array i.e; int, float, char, etc.
  2. array_name - Declaring the name.
  3. size - Declaring the number of elements in an array

Example

#include <stdio.h>

int main() {
    int numbers[5] = {1, 2, 3, 4, 5};

    printf("Element at index 0: %d\n", numbers[0]);
    printf("Element at index 2: %d\n", numbers[2]);

    return 0;
}

See how the array works

  1. int numbers[5] declares 5 the size of the array.
  2. numbers[0] gets the first value in the array.

Modifying an Array

Using the index we can change or modify the values in an array.

Example

#include <stdio.h>

int main() {
    int numbers[5] = {1, 2, 3, 4, 5};

    numbers[1] = 6;
    numbers[2] = numbers[1];
    
    printf(numbers[1]);
    printf(numbers[2]);

    return 0;
}

Using Loops

We can access, modify the array using loops.
Using iterations in for and while loops we can access them through index.

Example

#include <stdio.h>

int main() {
    int numbers[5] = {1, 2, 3, 4, 5};

    for (int i = 0; i < 5; i++) {
        printf("%d ", numbers[i]);
    }

    return 0;
}

Quick Recap - Topics Covered

C Arrays
Modifying an Array
Using loops in an Array

Practice With Examples in Compilers

The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compiler.

Example JS

Example 1 Example 2 Example 3 Example 4 Example 5

Quiz


FEEDBACK