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

Describe newline escape sequence with a sample program?

647


What are identifiers in c?

628


How does selection sort work in c?

617


Are c and c++ the same?

623


Can math operations be performed on a void pointer?

583






Define recursion in c.

695


In C language, a variable name cannot contain?

737


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

1735


What is the difference between declaring a variable and defining a variable?

716


what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

1896


Why is c used in embedded systems?

606


What is the easiest sorting method to use?

632


What is preprocessor with example?

578


What is the purpose of macro in C language?

657


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

1774