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

Answer Posted / koshy

#include "stdio.h"
main()
{
char str="hello world";
char i,j,a,b,len;

len=((const char *)str);
printf("char to be inserted:");
scanf("%d",&a);

printf("at position");
scanf("%d",&b);

for(i=0;i<len;i++)
{
temp=str[b];
str[b]=a;
str[b+1]=temp;
for(j=b+1;(j<len) &&(str[j]!=0);j++)
{
str[j+1]=str[j];
}

}






}

Is This Answer Correct ?    19 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is file a keyword in c?

503


What is a protocol in c?

559


Is r written in c?

724


What is the difference between test design and test case design?

1570


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1329






Explain how are portions of a program disabled in demo versions?

655


How do you define a string?

655


Write a program on swapping (100, 50)

638


What is union and structure?

574


What is #define used for in c?

615


Why can’t constant values be used to define an array’s initial size?

836


When should the const modifier be used?

658


What is the general form of #line preprocessor?

587


Why c is called a mid level programming language?

607


What are extern variables in c?

549