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

What is a static member?

1000


What is expression parser in c++

2412


Is it possible to use a new for the reallocation of pointers ?

990


What does new return if there is insufficient memory to make your new object?

975


What is switch case in c++ syntax?

1047


Which one is better- macro or function?

1122


How do you write a function that can reverse a linked-list?

1049


What do you mean by a template?

1016


What is malloc in c++?

967


What is endianness?

1038


Differentiate between a pointer and a reference with respect to c++.

1181


What is constructor and destructor in c++?

1057


What are c++ data types?

1098


What is c++ coding?

1126


Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300

2169