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
What are the methods of exporting a function from a dll?
Is java as fast as c++?
How do you master coding?
What is static in c++?
List down the guideline that should be followed while using friend function.
In inline " expression passed as argument are evalauated once " while in macro "in some cases expression passed as argument are evaluated more than once " --> i am not getting it plz help to make me understand....
What is function prototyping?
Can a list of string be stored within a two dimensional array?
Give example of a pure virtual function in c++?
Is it possible to pass an object of the same class in place of object reference to the copy constructor?
What is the fastest c++ compiler?
Is c++ the best programming language?
How would you implement a substr() function that extracts a sub string from a given string?
Write about the local class and mention its use?
List the types of polymorphism in c++?