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
What do you know about the use of bit field?
What is the purpose of clrscr () printf () and getch ()?
How variables are declared in c?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
Explain what is the difference between a string and an array?
How to get string length of given string in c?
What are examples of structures?
What does node * mean?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Give the rules for variable declaration?
What are the properties of union in c?
Why doesnt that code work?
What is the method to save data in stack data structure type?
What is a memory leak? How to avoid it?
How can I pad a string to a known length?