0% found this document useful (0 votes)
5 views1 page

Program-12 Array Insertion Logic

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Program-12 Array Insertion Logic

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<html>

<body>
<script language="javascript" type="text/javascript">
var a=new Array(20);
var N=parseInt(prompt("Enter size of array:"));
for(i=0;i<N;i++)
{
a[i]=parseInt(prompt("Enter array element:"+i));
}
document.write("<br>Array element before insertion:");
for(i=0;i<N;i++)
{
document.write(" "+a[i]);
}
var x=parseInt(prompt("Enter element for insertion"));
var Loc=parseInt(prompt("Enter location for insertion"));
for(i=N-1;i>=Loc-1;i--)
{
a[i+1]=a[i];
}
a[i+1]=x;
N++;
document.write("<br>Array element after insertion:");
for(i=0;i<N;i++)
{
document.write(" "+a[i]);
}
</script>
</body>
</html>

You might also like