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(); }

11th Jul 2022, 9:11 AM
Abhishek
Abhishek - avatar
3 ответов
+ 1
Update code? If not solved...
6th Aug 2022, 8:34 AM
Jayakrishna 🇮🇳
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...
11th Jul 2022, 9:46 AM
Jayakrishna 🇮🇳
0
Not working
13th Jul 2022, 1:44 AM
Abhishek
Abhishek - avatar