Sunday, 30 July 2017

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

Write a C program using array that take the value by user.

What is Array ?

Array is a type of data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string. Arrays are commonly used in computer programs to organize data so that a related set of values

 can be easily sorted or searched. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
All arrays include contiguous memory places. The lowest index corresponds to the first element and the highest index to the last element.

       Int a[10];        //integer array
       Char b[10];    //character array i.e. string
How to declare array ?
 To declare an array in C program, a programmer specifies the type of the elements and the number of elements required by an array as follows:

Array_type  Array_name [ Array_size ];


void main()
int a[5],i,j;
for (i=0;i<5;i++)
printf("Enter the marks of roll no %d ",i+1);
for (j=0;j<5;j++)
printf("\nMarks of roll no %d is %d ",j+1,a[j]);


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.


Post a Comment