Saturday, 29 July 2017

Write a C program that take the value by programmer by using array

Write a C program that take the value by programmer by using array:

What Is Array:

Array is a group of same data types.

Importance Of Array In C Programming:

Consider a scenario where in you want to store a hundred integer numbers, entered by user, in an effort to discover the average of them. To program this scenario you have got two ways:
 1) Define one hundred variable of integer type and at ultimate perform the common operation.
 2) Have a single integer array to store all values.

Which solution is better as according to you? Obviously the second one solution, it is convenient to store same data types in one single variable and later get access them using array index.

Array declaration:

data_type array-name [array_size]; 


float mark[5];

How to access the element of array?

You can use array  index to get right of entry to any element saved in array. Index starts with 0, because of this array_name[0] might be used to get right of entry to first element in an array.


void main()
int a[5]={55,34,12,54,32},i;
for (i=0;i<5;i++)
printf("\nMarks of roll no %d is %d ",i+1,a[i]);


Try it yourself.
If you have any problem you can tell me on comment box i will help you.

Viral Programs

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.