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
Why doesnt that code work?
What is difference between structure and union?
How do we open a binary file in Read/Write mode in C?
If you know then define #pragma?
What are types of functions?
Tell us something about keyword 'auto'.
How can I remove the leading spaces from a string?
How to define structures? ·
write a program to rearrange the array such way that all even elements should come first and next come odd
Can we access the array using a pointer in c language?
Explain Function Pointer?
What is the best way to comment out a section of code that contains comments?
What is the c value paradox and how is it explained?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
Describe explain how arrays can be passed to a user defined function