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
How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
What operator is used to access a struct through a pointer a) >> b) -> c) *
What happens when you make call 'delete this;'?
How would you find out if a linked-list is a cycle or not?
What is an operator function? Describe the function of an operator function?
What are c++ storage classes?
Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened
How to declaring variables in c++?
What is the advantage of an external iterator.
If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?
When is the copy constructor called?
Does there exist any other function which can be used to convert an integer or a float to a string?
Do you know what are pure virtual functions?
What is the difference between reference and pointer?