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
Describe newline escape sequence with a sample program?
What are identifiers in c?
How does selection sort work in c?
Are c and c++ the same?
Can math operations be performed on a void pointer?
Define recursion in c.
In C language, a variable name cannot contain?
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.
What is the difference between declaring a variable and defining a variable?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
Why is c used in embedded systems?
What is the easiest sorting method to use?
What is preprocessor with example?
What is the purpose of macro in C language?
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.