0
Insert an element in array at any position.the prog i need explaination and it can't work
#include<stdio.h> #include<conio.h> int main() { int a[100],i,pos,size,item;//a[100] denotes that we can create a block of 100 elements of a array printf("enter the size of the array \n"); scanf("%d",&size); printf("enter the elements for insertion in an array"); for(i=0;i<size;i++) { scanf("%d",&a[i]); } printf("enter the position number for to insert an element"); scanf("%d",&pos); printf("enter the item to be inserted"); scanf("%d",item); for(i=size;i>=pos;i--) { a[i]=a[i-1]; } a[pos]=item; size++; printf("The resultant array is"); for(i=0;i<size;i++) { printf("%d",a[i]); } getch(); }
3 Respostas
+ 1
Update code?
If not solved...
0
You are missing a & operator in
scanf("%d", &item) ;
canio.h is deprecated header file, don't use it. And instead getch() use getc() or getchar() if you need... Hope it helps...
0
Not working