Array Program
Array Program
#include<stdio.h>
int main()
{
int student[40],pos,i,size,value;
printf("enter no of elements in array of students:");
scanf("%d",&size);
printf("enter %d elements are:",size);
for(i=0;i<size;i++)
scanf("%d",&student[i]);
printf("enter the position where you want to insert the element:");
scanf("%d",&pos);
printf("enter the value into that position:");
scanf("%d",&value);
for(i=size-1;i>=pos-1;i--)
student[i+1]=student[i];
student[pos-1]= value;
printf("final array after inserting the value is");
for(i=0;i<=size;i++)
printf("%d",student[i]);
return 0;
}
Deletion in an Array
/* program to remove the specific elements from an array in C. */
#include <stdio.h>
#include <conio.h>
int main ()
{
// declaration of the int type variable
int arr[50];
int pos, i, num; // declare int type variable
printf (" \n Enter the number of elements in an array: \n ");
scanf (" %d", &num);
printf (" \n Enter %d elements in array: \n ", num);
int main()
{
int arr[10],i,n,ele;
printf("Enter array size: ");
scanf("%d", &n);
printf("Enter array elements: ");
for(i=0; i<n; i++)
{
scanf("%d",&arr[i]);
}
printf("Enter element to search: ");
scanf("%d", &ele);
}
printf("Element not found");
}