EmbLogic's Blog

inserting the element in array

#include<stdio.h>
2 main()
3 {
4     int i,j,k,l,m,A,v;
5     printf(“\nsize”);
6     scanf(“%d”,&k);
7     char x;
8
9     int a[k];
10
11     for(i=0;i<k;i++)
12     {
13         scanf(“%d”,&a[i]);
14     }
15
16     while(1){
17     getchar();
18     printf(“\npress i to insetre tyhe array”);
19     scanf(“%c”,&x);
20
21     if(x==’i’)
22     {
23         printf(“\naddress:- “);
24         scanf(“%d”,&A);
25
26         printf(“\nvalue:- “);
27         scanf(“%d”,&v);
28
29         for(j=0;j<=k-A;j++)
30         {
31             a[A+j++]=a[A+j];
32             a[A]=v;
33         }
34     }
35
36    for(i=0;i<k;i++)
37    {
38         printf(“\na[%d] = %d”,i,a[i]);
39    }}
40 }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>