VUSuperior Chat Room

Tuesday, 8 July 2014

CS101 - Introduction to Computing Assignment No. 03 Solution and Discussion Spring 2014 Due Date 11-July-14

<HTML>
<HEAD>
<TITLE>Sorting the Array</TITLE>
</HEAD>
<BODY bgcolor="#D3D3D3">
<h1> Implementation of Sort and Reverse Functions</h1>
<h2>Enter number of Element<h2>
<form>
<INPUT type="text" name="text" size="20" >
<INPUT TYPE="submit" VALUE="Take Input" onclick="" >
</form>
<form>
<INPUT TYPE="submit" VALUE="Ascending" onclick="">
<INPUT TYPE="submit" VALUE="Desending" onclick="">
</form>
</BODY>
</HTML>


<HTML>
<HEAD>
<TITLE>Sorting the Array</TITLE>
</HEAD>
<BODY bgcolor="#D3D3D3">
<h1> Implementation of Sort and Reverse Functions</h1>
<h2>Enter number of Element<h2>
<form>
<INPUT type="text" name="text" size="20" >
<INPUT TYPE="submit" VALUE="Take Input" onclick="" >
</form>
<form>
<INPUT TYPE="submit" VALUE="Ascending" onclick="">
<INPUT TYPE="submit" VALUE="Desending" onclick="">
</form>
</BODY>
</HTML>
<html>
<TITLE>Javascript Arrays</TITLE>
<BODY bgcolor="#F0F0F0">
<h1>Implementation of Sort and Reverse Functions </h>
<h2>Enter number of Elements</h2>
<form name="Anonymous Ghost">
<INPUT type="number" name="takeinput" id="valueField" size="30">
<Input type="button" name="name1" value="Take Input" onClick="a()"> </form>
<form name="Anonymous Ghost">
<Input type="button" name="name2" value="Ascending" onClick="b()">
<Input type="button" name="name3" value="Descending" onClick="c()">
</form>
</BODY>
<SCRIPT>
words = new Array (4);
function a() {
for ( k = 0 ; k < words.length ; k = k + 1 ) {
words[ k ] = window.prompt( "Enter word # " + k, "" ) ;
}
}
function b() {
words.sort( ) ;
document.write( "SORTED WORDS:" + "<BR>" ) ;
for ( k = 0 ; k < words.length ; k = k + 1 ) {
document.write( words[ k ] + "<BR>" ) ;
}
}
function c() {
words.sort( ) ;
words.reverse( ) ;
document.write( "SORTED WORDS:" + "<BR>" ) ;
for ( k = 0 ; k < words.length ; k = k + 1 ) {
document.write( words[ k ] + "<BR>" ) ;
}
}
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

<html>
<TITLE>Javascript Arrays</TITLE>
<BODY bgcolor="#F0F0F0">
<h1>Implementation of Sort and Reverse Functions </h>
<h2>Enter number of Elements</h2>
<form name="Anonymous Ghost">
<INPUT type="number" name="takeinput" id="valueField" size="30">
<Input type="button" name="name1" value="Take Input" onClick="a()"> </form>
<form name="Anonymous Ghost">
<Input type="button" name="name2" value="Ascending" onClick="b()">
<Input type="button" name="name3" value="Descending" onClick="c()">
</form>
</BODY>
<SCRIPT>
function a() {
var val = parseInt(document.getElementById('valueField').value)
var words = new Array(val);
for (k = 0; k < words.length; k = k + 1) {
words[k] = window.prompt("Enter word # " + k, "");
}
}
function b() {
words.sort( ) ;
document.write( "SORTED WORDS:" + "<BR>" ) ;
for ( k = 0 ; k < words.length ; k = k + 1 ) {
document.write( words[ k ] + "<BR>" ) ;
}
}
function c() {
words.sort( ) ;
words.reverse( ) ;
document.write( "SORTED WORDS:" + "<BR>" ) ;
for ( k = 0 ; k < words.length ; k = k + 1 ) {
document.write( words[ k ] + "<BR>" ) ;
}
}
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

<html>
<head>
<title>Javascript Arrays</title>
</head>
<body bgcolor="#F0F0F0">
<h1>Implementation of Sort and Reverse Functions </h1>
<h2>Enter number of Elements</h2>
<form name="Anonymous Ghost">
<INPUT type="number" name="takeinput" id="valueField" size="30" />
<Input type="button" name="name1" value="Take Input" onClick="a()" />
</form>
<form name="Anonymous Ghost">
<Input type="button" name="name2" value="Ascending" onClick="b()" />
<Input type="button" name="name3" value="Descending" onClick="c()" />
</form>
</body>
<script>
var words;
function a() {
var val = parseInt(document.getElementById('valueField').value);
words = new Array(val);
for (k = 0; k < words.length; k = k + 1) {
words[k] = window.prompt("Enter String # " + k, "");
}
}
function b() {
words.sort( ) ;
document.write( "SORTED WORDS:" + "<BR>" ) ;
for ( k = 0 ; k < words.length ; k = k + 1 ) {
document.write( words[ k ] + "<BR>" ) ;
}
}
function c() {
words.sort( ) ;
words.reverse( ) ;
document.write( "SORTED WORDS:" + "<BR>" ) ;
for ( k = 0 ; k < words.length ; k = k + 1 ) {
document.write( words[ k ] + "<BR>" ) ;
}
}
</script>
</html>

0 comments:

Post a Comment