Computer Science, asked by arti44, 1 year ago

how array is declared and define . write the program to input the array of integer and display it.

Answers

Answered by abhay1951
1
An array is a collection of fixed number of values of a single type. For example: if you want to store 100 integers in sequence, you can create an array for it.

int data[100];

The size and type of arrays cannot be changed after its declaration.

Arrays are of two types:

One-dimensional arrays

Multidimensional arrays (will be discussed in next chapter)

#include <stdio.h>
int main()
{ int avg = 0; int sum =0; int x=0;
/* Array- declaration – length 4*/
int num[4]; /* We are using a for loop to traverse through the array * while storing the entered values in the array */
for (x=0; x<4;x++)
{ printf("Enter number %d \n", (x+1));
scanf("%d", &num[x]);
}
for (x=0; x<4;x++)
{ sum = sum+num[x];
}
avg = sum/4;
printf("Average of entered number is: %d", avg);
return 0;
}


abhay1951: i have computer science in my 12
abhay1951: you are form CBSE ?
arti44: Okay, that's perfect
arti44: Yes
arti44: U ask me , so tuff question . so i can .....
abhay1951: ok you can
arti44: Ok u search on my cs question and give me reply
abhay1951: ok i will give
abhay1951: your answers
arti44: It is aPattern related question
Answered by Anonymous
1

Through these I hope u can able to write program

Attachments:
Similar questions