#include<stdio.h>
#include<conio.h>
void main()
{ int pos,val,i,a[100],n;
clrscr();
printf("enter elements of array");
for(i=0;i<5;i++){
scanf("%d",&a[i]); }
printf("\nEnter the position for the new element:\t");
scanf("%d",&pos);
printf("\nEnter the element to be inserted :\t");
scanf("%d",&val);
for(i=5-1;i>=pos;i--)
{
a[i+1]=a[i];
}
a[pos]=val;
n=n+1;
printf("\nThe array elements are:\n");
for(i=0;i<=5;i++){
printf("%d\t",a[i]);
}
getch();
}
#include<conio.h>
void main()
{ int pos,val,i,a[100],n;
clrscr();
printf("enter elements of array");
for(i=0;i<5;i++){
scanf("%d",&a[i]); }
printf("\nEnter the position for the new element:\t");
scanf("%d",&pos);
printf("\nEnter the element to be inserted :\t");
scanf("%d",&val);
for(i=5-1;i>=pos;i--)
{
a[i+1]=a[i];
}
a[pos]=val;
n=n+1;
printf("\nThe array elements are:\n");
for(i=0;i<=5;i++){
printf("%d\t",a[i]);
}
getch();
}
No comments:
Post a Comment