Program to perform operation on array in C language | codeswithabhi
In this tutorial you will learn,
First see what is an array?
Array is the collection of homogeneous data items that share a common name , Array contain similar kind of values on a same name it allocate contiguous or sequential memory. for more visit - Array in C-Programming. | Codes With Abhi
* Declaration of an array:-
data type array name [ array size ] ;
Operation on an array in C programming:-
- Create an array.
- Insert element into an array.
- Delete element from an array.
- Display element of an array.
For more
Let's take a program as an example:-
Write a program to perform operation on an array in c programming
Before starting a program, first create an array
now here we create an array and we also insert some element
___________________array________________
0 0 | 1 | 2 | 3 | 4 |
#include
#include
void main()
{
int array[ ], n,i,loc; //creation of array
printf("\n How many element you want");
scanf("%d",&n);
printf("\n enter %d element', n);
for(i=0 ; i<=4 ; i++)
{
scanf("%d",&array[i]); //inserting values into an array
}
printf("\n you enter tha following values=");
for(i=0 ; i
{
printf("\n%d", array[i]); //print the values ---Displaying
}
printf("\n enter the location where you want to delete");
scanf('%d", &loc);
if(loc>n)
{
printf("\n Deletionn not possible");
}
else
{
i=0;
while(i!=loc-1)
{
i++;
}
while(i
{
array[i]=array[i+1];
i++;
}
}
}
So here we are perform all four operation on array in C programming.
Click below for more
- c programming online compilerc programming functionsc programming stringc programming onlinec programming compilerc programming in vs codehow learn c programmingc programming softwarec programming reverse numberc programming for loopc programming practicec programming for beginnersc programming examples with outputc programming recursion
0 comments:
Post a Comment
If you have any doubt, please let me know