answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

void main()

{

int a[20],i,j,n;

clrscr();

printf("Enter the no of element you want to insert in the array : ");

scanf("%d",&n);

printf(" Enter the Array element : ");

for(i=0;i<n;i++)

{

scanf("%d",&a[i]);

}

printf("The array is : ");

for(i=0;i<n;i++)

{

printf("%d",a[i]);

}

printf(" Enter the element which you want to insert");

scanf("%d",&j);

printf("The array is : ");

for(i=0;i<n+1;i++)

{

if(i==n)

a[i]=j;

printf("%d",a[i]);

}

getch();

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

How are arrays processed?

Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.


Can you perform insertion and deletion in an array?

You can, but it's not as straightforward as inserting or deleting from a list. This is simply because arrays are not intended for insertions or deletions other than at the end of the array. This is because an insertion requires that the entire array be reallocated (which may require the array to be copied in its entirety) simply in order to make room for the new element, which can then simply be inserted in the unused element at the end of the new array. To insert elsewhere in the array, all the elements following the insertion point need to be copied (for a second time) into the next element, starting with the last used element. the entire process can prove quite costly, especially if the elements are complex objects which would require their copy constructors to be invoked at least once and possibly twice. This is why it is generally better to use arrays of pointers to objects rather than arrays of objects, as copying a pointer is more efficient than copying an object. However, if your array undergoes frequent resizing in order to accommodate insertions and deletions, then you really would be better off using a list.


Write a c program to find the maximum value of 25 element in an array?

int findMax(int *array) { int max = array[0]; for(int i = 1; i &lt; array.length(); i++) { if(array[i] &gt; max) max = array[i] } return max; }


What are the advantages of insertion sort?

It is less efficient on list containing more number of elements. As the number of elements increases the performance of the program would be slow. Insertion sort needs a large number of element shifts.


Will an array element be deleted when you retrieve it from the array?

You cannot delete from an array.

Related Questions

How are arrays processed?

Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.


How do you write a program that accepts 50 integer values and sort them in basic programming?

Create an array with 50 elements and input the integers one a time, filling the array. Use an insertion sort on the array for each input except the first. Alternatively, input the values first and then use insertion sort.


What will happen if you try to write to an array element larger than your array?

The results of that programming error is undefined. You must NEVER EVER write, or EVEN READ an array element beyond the allocated size of the array. Period.I would flunk a student that consistently did this, and I would fire a programmer that did the same.


Write an Algorithm to delete a last element from the array?

// Assuming you dynamically allocated this array using "new"... delete array[arraysize - 1]; arraysize--;


Can you compute one array in c say and then assign b to a?

Yes, you can. You have to do that in the following way. Each element of A should be assighed each element of B. You have to do it manually means you have to write a loop which will do it for you. In C array A = array B is not correct.


Can you perform insertion and deletion in an array?

You can, but it's not as straightforward as inserting or deleting from a list. This is simply because arrays are not intended for insertions or deletions other than at the end of the array. This is because an insertion requires that the entire array be reallocated (which may require the array to be copied in its entirety) simply in order to make room for the new element, which can then simply be inserted in the unused element at the end of the new array. To insert elsewhere in the array, all the elements following the insertion point need to be copied (for a second time) into the next element, starting with the last used element. the entire process can prove quite costly, especially if the elements are complex objects which would require their copy constructors to be invoked at least once and possibly twice. This is why it is generally better to use arrays of pointers to objects rather than arrays of objects, as copying a pointer is more efficient than copying an object. However, if your array undergoes frequent resizing in order to accommodate insertions and deletions, then you really would be better off using a list.


Write a c program to find the maximum value of 25 element in an array?

int findMax(int *array) { int max = array[0]; for(int i = 1; i &lt; array.length(); i++) { if(array[i] &gt; max) max = array[i] } return max; }


What is the value of the kth smallest element in the given array?

The value of the kth smallest element in the array is the kth element when the array is sorted in ascending order.


Can linked list represent in array if yes show how insertion and deletions can perform in array representation of inked list?

yes


Will an array element be deleted when you retrieve it from the array?

You cannot delete from an array.


What are the advantages of insertion sort?

It is less efficient on list containing more number of elements. As the number of elements increases the performance of the program would be slow. Insertion sort needs a large number of element shifts.


Write c program to find median?

If you are using an array : sort using qsort() then take middle element.