MCSL 216 MCA NEW Practical ~ common questions suggestions
Topic: JS VALIDATION
Q1. Design a form for booking room through a Hotel website.
The form should have relevant fields (make suitable assumptions). Further, the
form should have Submit and Reset button. Now, perform following:
Marks: 20
Solution:
<html> <title>hotel form
booking</title> <body> <br> <h2>Hotel
Form</h2> <br> <form
id="booking_form"> <label
for="p_name">Person Name</label> <br> <input
type="text" id="p_name" name="p_name"> <br> <label
id="p_name_msg" style="color: red;">Please enter your
name</label> <br> <label
for="email">Email Address</label> <br> <input type="email"
id="email" name="email"> <br> <label
id="email_msg" style="color: red;">Please enter email
address</label> <br> <label
for="phone">Phone Number</label> <br> <input
type="number" id="phone" name="phone">
<br> <label
id="phone_msg" style="color: red;">Please enter phone
number</label> <br> <label
for="booking_start">Start Booking</label> <br> <input
type="date" id="booking_start"
name="booking_start"> <br> <label
id="booking_start_msg" style="color: red;">Please
enter start of booking date</label> <br> <label
for="booking_end">End Booking</label> <br> <input
type="date" id="booking_end"
name="booking_end"> <br> <label
id="booking_end_msg" style="color: red;">Please enter
end of booking date</label> <br> <label
for="adult">Number of Adults</label> <br> <input
type="number" id="adult" name="adult">
<br><br> <label
for="childs">Number of Childs</label> <br> <input
type="number" id="childs" name="childs">
<br><br> <input
type="submit" value="submit"> </form> <script>
document.getElementById('p_name_msg').style.display =
"none";
document.getElementById('email_msg').style.display = "none";
document.getElementById('phone_msg').style.display = "none";
document.getElementById('booking_start_msg').style.display =
"none";
document.getElementById('booking_end_msg').style.display =
"none";
document.getElementById("booking_form").addEventListener("submit",
function(e){
e.preventDefault(); let count=0; if(document.getElementById('p_name').value){ count++; }else{
document.getElementById('p_name_msg').style.display =
"block"; }
if(document.getElementById('email').value){ count++; }
if(document.getElementById('phone').value){ count++; }
if(document.getElementById('booking_start').value){ count++; }
if(document.getElementById('booking_end').value){ count++; } if(count == 5){
document.getElementById('booking_form').submit(); }else{
alert("please enter required fields values"); } }); </script> </body> </html> |
Q2. Design a form to reserve seat in a tourist bus, through
its website. The forum
should have relevant fields (make suitable assumptions). The
form should have
submit and reset button. Now, perform following: 20
(a) Use java script to validate all the fields in the form.
(b) Submit button should enter the data of fields in to the
database.
(c) Error message should be shown if any text field is left
blank.
(d) Reset button should reset all the fields to blank.
Marks: 20
Q3. Design a form to take admission in any course offered by
any university through
its website. The form should have relevant fields (make
suitable assumptions).
The form should have submit and re-set button. Now perform
the following: 20
(a) Use java script to validate all the fields in the form.
(b) Submit button should enter data of fields in to the
database.
(c) Error message should be shown if any text field is left
blank.
(d) Reset button should reset all the fields to blank.
Marks: 20
Q4. Design a form for student satisfaction survey for
various course offered by some
Department of some University. The form should have relevant
fields (make
suitable assumptions). The form should have submit and reset
button. Now,
perform the following:
(a) Use java script to validate all the fields in the form.
(b) Submit button should enter the data of fields in the
database.(c) Error message should be shown if text field is left blank.
(d) Reset button should reset all the fields to blank.
Marks: 20
solution
<!DOCTYPE html> <html lang="en"> <head> <meta
charset="UTF-8"> <meta
name="viewport" content="width=device-width,
initial-scale=1.0"> <title>form
select</title> </head> <body> <br> <form> <label
for="university">university</label><br> <select
name="university" id="university">
<option>select any university</option> <option
value="ignou">ignou</option> <option
value="cu">calcutta university</option> <option
value="ju">jadavpur university</option> <option
value="pu">presidency university</option> <option
value="tu">techno india university</option> </select> <br><br> <label
for="course"></label> <select
name="course" id="course"></select> </form> <script> let courses = { "ignou":
["web development","app development"], "cu" :
["literature","history","pol science"], "ju" :
["mob soft dev","hardware","geo politics"], "pu" :
["discreate maths","rabindra sangeet","journal
english"], "tu" :
["windows","A.I","robotics"], };
document.getElementById('university').addEventListener("change",
function () {
document.getElementById('course').options.length = 0; let uni =
document.getElementById('university').value; let select =
document.getElementById('course'); if(courses[uni]){ courses[uni].forEach((ind,
val) => { let option
= document.createElement("option");
option.value = ind;
option.innerHTML = ind;
select.appendChild(option); }); } }); </script> </body> </html> |
Topic: Searching
Algos:
Q1. Implement binary search algorithm and apply C code as
well. Time complexity.
References: https://www.programiz.com/dsa/binary-search
/* binary search */ while(low <= high){ mid = (low+high)/2; if(arr[mid] == find){ printf("element
found"); flag++; break; } else if(arr[mid] < find){ low = mid + 1; } else if(arr[mid] >
find){ high = mid - 1; } } if(flag == 0){ printf("element not
found"); } |
Q2. Implement bubble
sort algo
References: https://www.javatpoint.com/bubble-sort-program-in-c
/* BUBBLE SORT */ printf("before bubble sort
array: "); for(i=0;i<size;i++){ printf("%d \t",
arr[i]); } for(i=0;i<size-1;i++){
for(j=0;j<(size-i)-1;j++){ if(arr[j] > arr[j+1]){ int temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } printf("after sort
array: "); for(i=0;i<size;i++){ printf("%d \t",
arr[i]); } |
Q3. Implement selection sort , insertion sort and merge sort
in c.