0

please guys can anyone of you tell me where is the problem in this code

#include<stdio.h> int main(){ int N ,i ,P,position,value ; int T[50]; printf("Enter number of elements in the array \n"); scanf("%d",&N); for(i=0;i<N;i++){ P=T[i]; printf("enter the values of elements T[%d]=\n",i); scanf("%d",&P); printf("T[%d]=%d\n",i,P);} printf("Please enter the location where you want to insert an new element "); scanf("%d",&position); printf("\n please enter the value "); scanf("%d",&value); for(i=N-1;i>=position-1;i--){ T[i+1]=T[i]; T[position-1]=value;} for(i=0;i<=N;i++){ printf("%d\n",T[i]);} }

22nd Nov 2020, 11:12 PM
Nouhaila
Nouhaila - avatar
6 Answers
+ 1
See the notes in the edited code https://code.sololearn.com/cto4952ZhCX7/?ref=app
23rd Nov 2020, 4:43 AM
Ipang
+ 2
Thanks
23rd Nov 2020, 11:51 AM
Nouhaila
Nouhaila - avatar
+ 1
Please save the code in SoloLearn and share the code link instead of raw text like this. It is uneasy to work with, and it's hard to point line numbers. Follow this guide to sharing links 👍 https://www.sololearn.com/post/75089/?ref=app
23rd Nov 2020, 12:40 AM
Ipang
+ 1
So you want to fill 50 elements in array, then insert 1 new value to replace an existing element; is this what you want or am I misunderstanding?
23rd Nov 2020, 1:04 AM
Ipang
0
Thanks
23rd Nov 2020, 12:59 AM
Nouhaila
Nouhaila - avatar
0
Yes that's what I want
23rd Nov 2020, 1:10 AM
Nouhaila
Nouhaila - avatar