Computer Science, asked by jayaruba281, 8 months ago

all the array program ​

Answers

Answered by MagicalCupcake
4

\huge{\blue{\fbox{\purple{\bigstar{\mathbf{\red{Array:-}}}}}}}

An array is a variable that can store multiple values. For example, if you want to store 100 integers, you can create an array for it.

\rule{200}3

\orange\bigstarIt is possible to initialize an array during declaration. For example,

int mark[5] = {19, 10, 8, 17, 9};

\orange\bigstarYou can also initialize an array like this.

int mark[] = {19, 10, 8, 17, 9};

Here, we haven't specified the size. \orange\bigstarHowever, the compiler knows its size is 5 as we are initializing it with 5 elements.

// Program to take 5 values from the user and store them in an array

// Print the elements stored in the array

#include <stdio.h>

int main() {

int values[5];

printf("Enter 5 integers: ");

// taking input and storing it in an array

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

scanf("%d", &values[i]);

}

printf("Displaying integers: ");

// printing elements of an array

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

printf("%d\n", values[i]);

}

return 0;

}

Similar questions