Array in C

Array: An array is a collective name given to a group of similar quantities. If we would like to store 100 employee salary then we will should create an array of size 100 (int salary[100]) These similar elements could be all integers or all floats or all characters etc.

In this video I have explained about Array in C:

1. Explain Array & its need.

2. Code for entering & gettting value from Array in C.

3. Type of Array.

a. Single Dimenstion Array.

b. Multi Dimenstion Array.

Secondly I have shown code explaining how you can entering & gettting value from Array in C.


/*
Developed By:Prof. Vinod Pillai
vinodthebest@gmail.com
Array in C.
*/

#include

int main()
{
//Single Dimenstion Array
int array[5];
int i,j,rel=0;
//Multi Dimenstion Array 3 Rows & 5 Coloums each
int arr[3][5];

printf("\n Enter the Value of Array:");
scanf("%d",&array[0]);

printf("\n The result is :%d",array[0]);

//Getting the Value
for(i=0;i<5;i++)
{
printf("\n Enter the Value of Array:");
scanf("%d",&array[i]);
}

//Printing the Value
for(i=0;i<5;i++)
{
printf("\n The result is :%d",array[i]);
rel=rel+array[i];
}

printf("\nThe sum of Array values is:%d",rel);

//***************************************************************
rel=0;
//Two Dimenstion Array Getting the Value
for(i=0;i<3;i++)
{
for(j=0;j<5;j++)
{
printf("\n Enter the Value of Array:");
scanf("%d",&arr[i][j]);
}
}

//Printing the Value
for(i=0;i<3;i++)
{
for(j=0;j<5;j++)
{
printf("\n The result is :%d",arr[i][j]);
rel=rel+arr[i][j];
}
}

printf("\n\nThe sum of Array values is:%d",rel);
return 0;
}

Advertisements

Leave a comment

Filed under C Programming, General

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s