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


Please Help Members By Posting Answers For Below Questions

What is difference between structure and union in c programming?

771


By using C language input a date into it and if it is right?

797


What is file in c preprocessor?

875


Explain what is a program flowchart and explain how does it help in writing a program?

858


Describe explain how arrays can be passed to a user defined function

841


the question is that what you have been doing all these periods (one year gap)

1845


What are reserved words with a programming language?

825


How many identifiers are there in c?

762


What is ## preprocessor operator in c?

811


Do character constants represent numerical values?

1068


Explain pointer. What are function pointers in C?

823


What do you mean by c?

782


What is wrong in this statement? scanf(“%d”,whatnumber);

970


What functions are in conio h?

879


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

981