write a program to insert an element at the specified
position in the given array in c language

Answer Posted / ashok kannan

Hi to all,

/* program to insert element in the array at given
position*/
#include<stdio.h>
#include<conio.h>
void main()
{
char c,t2,t1,a[100]="This is c program";
int n,i;

printf("Enter the position and the element\n");
scanf("%d%c",&n,c);

for(i=n,t1=a[i];a[i]!='\0';i++)
{
t2=a[i+1];
a[i+1]=t1;
t1=t2;
}
a[n]=c;

printf("%s",a);
getch();

}

Is This Answer Correct ?    19 Yes 46 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between pass by reference and pass by value?

658


What is volatile, register definition in C

691


Is c is a middle level language?

597


What is a loop?

556


GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

684






Is c is a low level language?

566


What are identifiers and keywords in c?

573


What is meant by errors and debugging?

649


An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode

609


Is malloc memset faster than calloc?

617


How do you convert strings to numbers in C?

710


Is c# a good language?

610


What is the scope of global variable in c?

558


Explain do array subscripts always start with zero?

761


Is it valid to address one element beyond the end of an array?

675