Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to insert an element into an array

Answer Posted / jyoti sur

#include<stdio.h>
#include<conio.h>
void main()
{
int pos,k,n,a[30];
int i;
clrscr();
printf("enter no.of element in array\n");
scanf("%d",&n);
printf("enter the elements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("your array is:\n");
for(i=0;i<n;i++)
{
printf("%6d",a[i]);
}
printf("\nenter the no.for insertion\n");
scanf("%d",&k);
printf("\n\nenter the position");
scanf("%d",&pos);
--pos;

if(pos<n)
{
for(i=n;i>=pos;i--)

a[i+1]=a[i];
a[pos]=k;
n++;

}
else
printf("\n outside the array");
printf("the new array is:");
for(i=0;i<n;i++)
{
printf("%6d",a[i]);
}
}

Is This Answer Correct ?    91 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?

1453


Explain the register storage classes in c++.

1158


what is upcasting in C++?

1128


How do you flush a buffer in c++?

1065


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

2538


What is the basic structure of c++ program?

1045


Is python written in c or c++?

1106


What is the best free c++ compiler for windows?

1061


How do you clear a map in c++?

1076


What are vtable and vptr?

1086


What are friend classes? What are advantages of using friend classes?

1051


What is the main use of c++?

1071


Can recursive program be written in C++?

1192


What is a static element?

1023


Difference between declaration and definition of a variable.

1098