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
How can you be sure that a program follows the ANSI C standard?
How can I read a binary data file properly?
What is the difference between text and binary i/o?
Give me the code of in-order recursive and non-recursive.
What is difference between scanf and gets?
What is a void pointer? When is a void pointer used?
How do I get an accurate error status return from system on ms-dos?
What are the disadvantages of external storage class?
Why is struct padding needed?
write a program to create a sparse matrix using dynamic memory allocation.
Explain union. What are its advantages?
count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array
What are enumerated types?
What is sizeof return in c?
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.