Pages

Write a program in c language to insert a new element in array.

Monday, 27 May 2013

#include <stdio.h>
#include <conio.h>
int main()
{
    int i, a[10], loc, item;
    for(i=0; i<=9; i++)
    {
             printf("Enter number %d: ", i);
             scanf("%d", &a[i]);
    }
   
    printf("Enter location where you want to enter number: ");
    scanf("%d", &loc);
    printf("Enter number: ");
    scanf("%d", &item);
    for(i=10; i>loc; i--)
    {
             a[i]=a[i-1];
    }
    a[loc]=item;
    for(i=0; i<=10; i++)
    {
             printf("%d ", a[i]);
            // scanf("%d", &a[i]);
    }
    getch();
}
 

Search Box

Most Reading

Contact Form

Name

Email *

Message *