Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a program to insert an element at the specified
position in the given array in c language

Answers were Sorted based on User's Feedback



write a program to insert an element at the specified position in the given array in c language..

Answer / prashant tyagi

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,item,n,a[10],loc,flg;
clrscr();
printf("Enter the limit N : ");
scanf("%d",&n);
if(n<=10)
{
for(i=1;i<=n;i++)
{
printf("a[%d] = ",i);
scanf("%d",&a[i]);
}
printf("\nEnter the Location = ");
scanf("%d",&loc);
for(j=1;j<=n;j++)
{
if(loc==j)
{
flg=1;
printf("Insert = ");
scanf("%d",&item);
for(i=n;i>=loc;i--)
{
a[i+1]=a[i];
}
a[loc]=item;
}
}
if(flg==1)
{
n++;
}
else
{
printf("Location not Found");
}

printf("\nNew List\n");
for(i=1;i<=n;i++)
{
printf("\n%d",a[i]);
}
}
else
{
printf("Limit is not Valid ");
}
getch();
}

Is This Answer Correct ?    24 Yes 5 No

write a program to insert an element at the specified position in the given array in c language..

Answer / 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

write a program to insert an element at the specified position in the given array in c language..

Answer / ajith.s uit adoor(2008-2010)

#include<stdio.h>
#include<conio.h>
void main()
{

int i,j,item,n,a[10],u,k;clrscr();

printf("enter the limit\n");
scanf("%d",&n);
if(n>=10)
{
printf("Array exceed limit .correct the limit value below
10 \n");
}
else
{

printf("enter the inserted element");
scanf("%d",&item);

printf("enter the position\n");
scanf("%d",&k);
if(k<=n||k<=10)
{
printf("enter the terms\n");
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
printf("inserted list\n");
for(i=1;i<=n;i++)
{
printf("%d\n",a[i]);
}
printf("inser list\n");
j=n;
while(j>=k)
{
a[j+1] =a[j];
j=j-1;
}
a[k]=item;

for(i=1;i<=n+1;i++)
{
printf("%d\n",a[i]);
}
}
else
{
printf("postion given in below limit not equal to \n");
}
}
getch();
}

Is This Answer Correct ?    12 Yes 12 No

write a program to insert an element at the specified position in the given array in c language..

Answer / 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

write a program to insert an element at the specified position in the given array in c language..

Answer / bhagya

#include<stdio.h>
#include<conio.h>
void main()
{
char c[20]="this is a string";
int n;
printf("en etr index value to which the element has to
be inserted");
c[n]=getchar();
printf("the string after inserted");
printf("%s",c);
getch();
}

Is This Answer Correct ?    25 Yes 55 No

Post New Answer

More C Interview Questions

Why clrscr is used after variable declaration?

0 Answers  


What is a static function in c?

0 Answers  


What is operator precedence?

0 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it

7 Answers  


State two uses of pointers in C?

0 Answers   Aspire, Infogain,


What is the use of getchar() function?

0 Answers  


declare afunction pointer to int printf(char *)?

1 Answers   HCL,


What are the rules for identifiers in c?

0 Answers  


Is sizeof a keyword in c?

0 Answers  


what is void pointer?

2 Answers  


When should structures be passed by values or by references?

0 Answers   Adobe,


How to establish connection with oracle database software from c language?

0 Answers  


Categories