We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

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

Objectives:

The objective of this assignment is to introduce students with the concepts of Arrays, conditions, loops in JavaScript and making interactive web pages with their combination.

Lectures Covered:    21 - 26

Instructions:

• Your assignment must be submitted in “.html” format. Assignment submitted in any other format will not be accepted and will be awarded with zero marks.
 Assignment:                                                                                                                         Marks 20  You are required to develop a web page which will create an array of strings and then it will sort the array in ascending and descending orders. The number of elements of the array will be specific by the user at run time.  Detailed Description: 1. You are required to develop a web page as shown below: 2. User will specify the number of array elements in the text field and then click on “Take Input” button. This process will create an array of specified number in the text field and also take input from user in those elements. Example is shown in the figure below:   Here 5 is number of elements of the array. On clicking on “Take Input” button, the Prompt window should display asking for input in the array elements one by one.   3. After taking inputs, if the user clicks on “Ascending” button, then the entered values should be sorted and displayed in ascending order and if user clicks on “Descending” button, then it should be sorted in descending order. Example is shown in the figures below assuming that the inputs are “Table”, “Chair”, “Door”, “Fan”, and “House”. Hints: You can make this assignment by making some modifications in the example program given in Lecture 26 Event handlers and functions are the core concepts for solving this assignment NOTE: You have to modify the font size of the output array otherwise marks will be deducted.

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?

Views: 10326

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

### Replies to This Discussion

sir is main jo list ai hui ha assignment mai wo kio ni show hoti?

table chair etc.is k mutallak plz btain na kch.ye point smajh ni aa raha..

Bro, Assignment mein sirf aek example di gayi hai k agar user ye 5 words enter page mein enter karien to wo sort ya unsort kar diye jaein. Aon words ka page ki coding se koi relation nahi,

CS101 assignment 3 SOLUTION spring 2014

Attachments:

function a() {
var val = parseInt(document.getElementById('valueField').value)
var words = new Array(val);
Please explain me this ... smjh hi nahi arha kia likha hai

must take web development lecture after this one

wohi words nazer ni aaye gy jo assignment men hy

blka wo words nazer aye gy jo ap khd prompt window men likho gy

Just Follow Step By Step Procedure..

02: Put Ur Code.

<html>

<title>Javascript Arrays</title>

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

03: Save where u want to do. (Downloads or Desktop or any where)

Ctrl+S > give ur VU ID> . HTML n Click Save.

04: Open ur Chrome file.

05: See ur work in browser.. Give the input '5' n click Take Input.

06:  Give the Name of things..n click ok

07: Now click Ascending button. u 'll see like this..

08: Now click Descending button. u 'll see like this..

U can check ur HTML Code with ONLINE HTML EDITOR.

Just put ur code here and check..

http://www.onlinehtmleditor.net/

## Latest Activity

58 seconds ago
+ ! ! ! ❣ maho ❣ ! + joined + M.Tariq Malik's group

### MTH603 Numerical Analysis

4 minutes ago
+ ! ! ! ❣ maho ❣ ! + posted a discussion

### Ary kia krti ho??????????????????

5 minutes ago
8 minutes ago
+ıllıllı \$µǥąя ǥ€ɲɨµ\$ ıllıllı+ liked Isha Chuhdary's discussion paka
11 minutes ago
12 minutes ago
14 minutes ago
Alisha Noor replied to Isha Chuhdary's discussion Bari
15 minutes ago
Isha Chuhdary replied to Isha Chuhdary's discussion Mera sher
17 minutes ago
Isha Chuhdary replied to Isha Chuhdary's discussion paka
18 minutes ago
+ıllıllı \$µǥąя ǥ€ɲɨµ\$ ıllıllı+ liked Isha Chuhdary's discussion Mera sher
24 minutes ago
26 minutes ago

1

2

3