Logo 
Search:

C Programming Forum

Ask Question   UnAnswered
Home » Forum » C Programming       RSS Feeds

need help urgently

  Asked By: Maya    Date: Sep 09    Category: C Programming    Views: 859
  

anybody can plz help me in insertion of element in matrix i shall b realy realy gratful

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Rajani Wali     Answered On: Sep 28

#include <stdio.h>

int main()
{
int array[100], position, c, n, value;

printf("Enter number of elements in array\n");
scanf("%d", &n);

printf("Enter %d elements\n", n);

for (c = 0; c < n; c++)
scanf("%d", &array[c]);

printf("Enter the location where you wish to insert an element\n");
scanf("%d", &position);

printf("Enter the value to insert\n");
scanf("%d", &value);

for (c = n - 1; c >= position - 1; c--)
array[c+1] = array[c];

array[position-1] = value;

printf("Resultant array is\n");

for (c = 0; c <= n; c++)
printf("%d\n", array[c]);

return 0;
}

///OUTPUT///


Enter number of elements in array
5
Enter 5 elements
2
5
4
3
8
Enter the location where you wish to insert an element
4
Enter the value to insert
10
Resultant array is
2
5
4
10
3
8







 
Didn't find what you were looking for? Find more on need help urgently Or get search suggestion and latest updates.




Tagged: