write a program to insert an element into an array
Answer Posted / sonia
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int a[10]={10,20,30,40,50,60,70,80,90};
int num,i,pos;
printf("enter the no which you want to insert");
scanf("%d",&num);
printf("enter the position");
scanf("%d",&pos);
if(pos<0 || pos>9)
{
printf("invalid position");
getch();
exit(0);
}
for(i=9;i>pos;i--)
a[i]=a[i-1];
a[pos]=num;
for(i=0;i<=9;i++)
printf(" %d",a[i]);
getch();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Can a constructor be private?
What is data types c++?
What's the order in which the local objects are destructed?
What language is a dll written in?
Why do we use using namespace std in c++?
What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack
What is the difference between the parameter to a template and the parameter to a function?
What is vector processing?
Eplain extern keyword?
How do you declare A pointer to a function which receives nothing and returns nothing
What is an overflow error?
Can there be at least some solution to determine the number of arguments passed to a variable argument list function?
What return value must conversion operators have in their declaration?
Why is c++ still used?
How would you use qsort() function to sort an array of structures?