C Language
Program No: 1
1) Deletion in array in C:
Coding
#include<stdio.h>
int main()
{
int std[50], size, i, n, p;
printf("Enter size:");
scanf("%d",&size);
printf("Enter elements:");
for(i=0; i<size; i++)
{
scanf("%d",&std[i]);
}
printf("Enter new elements:");
scanf("%d",&n);
printf("Enter the position=");
scanf("%d", &p);
for(i<size-1; i>=p-1; i--)
{
std[i+1]=std[i];
}
std[p-1]=n;
printf("updating elements");
for(i=0; i<size; i++)
{
printf("%d",std[i]);
}
return 0;
}
_________________________________________________________________________ __________________________________________________________________
Program No. 2
2) Insertion in Array in C:
Coding
#include<stdio.h>
int main()
{
int std[50], size, i, n, p;
printf("Enter size:");
scanf("%d",&size);
printf("Enter elements:");
for(i=0; i<size; i++)
{
scanf("%d",&std[i]);
}
printf("Enter new elements:");
scanf("%d",&n);
printf("Enter the position=");
scanf("%d", &p);
for(i<size; i>=p+1; i++)
{
std[i]=std[i+1];
}
std[p-1]=n;
printf("updating elements=");
for(i=0; i<size; i++)
{
printf("%d",std[i]);
}
return 0;
}
_________________________________________________________________________
__________________________________________________________________
Program No. 3
3) Array in C:
Coding
#include<stdio.h>
int main()
{
int arr[20],size,i,j;
printf("Enter size of an array=");
scanf("%d",&size);
printf("Enter element=");
for(i=0; i<size; i++){
for(j=i+1; j<=size; j++){
scanf("%d",&arr[i]);
if(arr[i]<arr[j]){
}
}
}
printf("Elements are=");
for(i=0; i<size; i++){
for(j=i+1; j<=size; j++){
printf("%d",arr[i]);
}
}
return 0;
}
__________________________________________________________________________
__________________________________________________