## JavaScript Programs

1.Write JavaScript code to print subtraction of 2 numbers.

<html>
<title>JS program to subtract two numbers</title>

<body>
<script>
var n1, n2, diff;
n1=parseInt(prompt("Enter first number:"));
n2=parseInt(prompt("Enter second number:"));
diff=n2-n1;
</script>
</body>
</html>

2.Write JavaScript code to print addition of 2 numbers.

<html>
<title>JS program to add two numbers</title>

<body>
<script>
var n1, n2, sum;
n1=parseInt(prompt("Enter first number:"));
n2=parseInt(prompt("Enter second number:"));
sum=n1+n2;
</script>
</body>
</html>

3.Write JavaScript code to print multiplication of 2 numbers.

<html>
<title>JS program to multiply two numbers</title>

<body>
<script>
var n1, n2, prod;
n1=parseInt(prompt("Enter first number:"));
n2=parseInt(prompt("Enter second number:"));
prod=n1*n2;
</script>
</body>
</html>

4.Write JavaScript code to print division of 2 numbers.

<html>
<title>JS program to divide two numbers</title>

<body>
<script>
var n1, n2, q;
n1=parseInt(prompt("Enter first number:"));
n2=parseInt(prompt("Enter second number:"));
q=n1/n2;
</script>
</body>
</html>

5.Write JavaScript code to print addition, subtraction, multiplication & division of 2 numbers.

<html>
<title>JS program to add, subtract, multiply, divide two numbers</title>

<body>
<script>
var n1, n2, s,d,m,q;
n1=parseInt(prompt("Enter first number:"));
n2=parseInt(prompt("Enter second number:"));
s=n1+n2;
d=n2-n1;
m=n1*n2;
q=n1/n2;
document.write("<br>Sum - " + s);
document.write("<br>Difference - " + d);
document.write("<br>Product - " + m);
document.write("<br>Division - " + q);
</script>
</body>
</html>

6.Write JavaScript code to display area of circle, accept value from user.
7.Write JavaScript code to print area of triangle.

<html>
<title>JS program to calculate area of circle</title>

<body>
<script>
var r, area;

area=3.14*r*r;
</script>
</body>
</html>

8.Write JavaScript code to calculate the average of three numbers.

<html>
<title>JS program to calculate average of three numbers</title>

<body>
<script>
var n1, n2, n3 avg;
n1=parseInt(prompt("Enter first number:"));
n2=parseInt(prompt("Enter second number:"));
n3=parseInt(prompt("Enter third number:"));
avg=(n1+n2+n3)/3;
</script>
</body>
</html>

9.Write JavaScript code to print perimeter of rectangle.

<html>
<title>JS program to calculate perimeter of rectangle</title>

<body>
<script>
length=parseInt(prompt("Enter length of the rectangle:"));

</script>
</body>
</html>

10.Write JavaScript code to print perimeter of trapezium.

<html>
<title>JS program to calculate perimeter of trapezium</title>

<body>
<script>
var a, b, c, d, p;
a=parseInt(prompt("Enter length of the first side of trapezium:"));
b=parseInt(prompt("Enter length of the second side of trapezium:"));
c=parseInt(prompt("Enter length of the third side of trapezium:"));
d=parseInt(prompt("Enter length of the fourth side of trapezium:"));

p=a+b+c+d;
</script>
</body>
</html>

11.Write JavaScript code to check whether the number is odd or even.

<html>
<title>JS program to check number is odd or even</title>

<body>
<script>
var n;
n=parseInt(prompt("Enter a number:"));
if(n%2==0)
else
</script>
</body>
</html>

12. Write JavaScript code to enter two values and display the largest.

<html>
<title>JS program to find largest number</title>

<body>
<script>
var n1, n2;
n1=parseInt(prompt("Enter first number:"));
n2=parseInt(prompt("Enter second number:"));
if(n1>n2)
alert("Larger number - " + n1);
else
alert("Larger number - " + n2);

</script>
</body>
</html>

13. Write JavaScript code to print multiplication table of 3.

<html>
<title>JS program to print multiplication table of 3</title>

<body>
<script>
var n=3, i;
document.write("Multiplication table of 3");
for(i=1;i<=10;i++)
{
document.write("<br>"+n+" * "+i+" = "+n*i);
}

</script>
</body>
</html>

14.Write JavaScript code to print numbers from 1 to 10.

<html>
<title>JS program to print numbers from 1 to 10</title>

<body>
<script>
var i;
document.write("Numbers from 1 to 10");
for(i=1;i<=10;i++)
{
document.write("<br>"+i);
}

</script>
</body>
</html>

15.Write JavaScript code to print sum of 50 natural numbers.

<html>
<title>JS program to print sum of 50 natural numbers.</title>

<body>
<script>
var i, sum=0;
document.write("Sum of numbers from 1 to 50");
for(i=1;i<=50;i++)
{
document.write("<br>"+i);
sum=sum+i;
}
document.write("<br>Sum - "+sum);

</script>
</body>
</html>

16.Write JavaScript code to print all even numbers from 10 to 50.

<html>
<title>JS program to print even numbers from 10 to 50</title>

<body>
<script>
var i;
document.write("Even Numbers from 10 to 50");
for(i=10;i<=50;i++)
{
if(i%2==0)
document.write("<br>"+i);
}

</script>
</body>
</html>

17.Write JavaScript code when user click on button, it will display sum of even numbers from 1 to 10.

<html>
<title>JS program to print sum of even numbers.</title>
<script>
function display_sum() {
var i, sum=0;

for(i=1;i<=10;i++)
{
if(i%2==0)
sum=sum+i;
}
document.getElementById("disp").innerHTML = "Sum of even numbers from 1to10 - " + sum;
}
</script>

<body>

<input type="button"  name="disp_sum" value="Display Sum" onclick="display_sum()">

<br>
<p id="disp">   </p>

</body>
</html>

18.Write JavaScript code to print all odd numbers from 50 to 100.

<html>
<title>JS program </title>

<body>
<h1>JS program to print odd numbers from 50 to 100</h1>
<script>
var i;
document.write("Odd Numbers from 50 to 100");
for(i=50;i<=100;i++)
{
if(i%2!=0)
document.write("<br>"+i);
}

</script>
</body>
</html>

19.Write JavaScript code to print factorial of 7 on button click.

<html>
<title>JS program - factorial of number</title>
<script>
function display_factorial(num) {
var i, f = 1;
for (i = num; i >= 1; i--) {
f=f*i;
}
document.getElementById("disp").innerHTML = "Factorial of 7 - " + f;
}
</script>

<body>
<h1>JS program to print factorial of number</h1>
<input type="button"  name="disp_fact" value="Display Factorial" onclick="display_factorial(7)">

<br>
<p id="disp">   </p>

</body>
</html>

20.Write JavaScript code to print square of a accepted number.

<html>
<title>JS program to display square of a number</title>

<body>
<script>
var n, r;
n=parseInt(prompt("Enter a number:"));
r=n*n
</script>
</body>
</html>

21.Write JavaScript code to count length of accepted string after click on the button.
<html>
<title>JS program</title>
<script>
function display_length() {
var str, len;
str = form1.str_box.value;
len = str.length;
document.getElementById("disp").innerHTML = "Length of String  - " + len;
}
</script>

<body>
<h1>JS program to print length of string</h1>
<form name="form1">
<input type="text" name="str_box" size=50>
<input type="button"  name="disp_strlen" value="Display Length" onclick="display_length()">
</form>
<br>
<p id="disp">   </p>

</body>
</html>

22.Write JavaScript code to accept two dates and find the difference in those dates.

<html>
<title>JS program</title>
<script>
function display_diff() {
var d1, d2, diff;
d1 = new Date(form1.date1.value);
d2 = new Date(form1.date2.value);
diff = (d2 - d1) / (1000 * 3600 * 24);
document.getElementById("disp").innerHTML = "Difference of dates in days  - " + diff;
}
</script>

<body>
<h1>JS program to display difference between dates</h1>
<form name="form1">
<input type="date" name="date1">
<br> <br>
<input type="date" name="date2">
<br> <br>
<input type="button"  name="disp_diff" value="Display Difference" onclick="display_diff()">
</form>
<br>
<p id="disp">   </p>

</body>
</html>

23.Write JavaScript code to take a input of string and reverse the string in output.
<html>
<title>JS program - revverse of string</title>
<script>
function display_reverse(str) {
var newstr;
newstr = str.split("").reverse().join("")
document.write("Reverse of String  - " + newstr);
}
</script>
<body>
<h1>JS program to reverse a string</h1>
<script>
var s;
s = prompt("Input a string");
display_reverse(s)
</script>
</body>
</html>

24.Write JavaScript code to input 3 digit number and find sum and product of its digit of the number use onblur event for the program.

25.Write JavaScript code to print factorial of accepted number.

## Saturday, 18 February 2023

### HTML PROGRAMS WITH SOLUTIONS HSC ONLINE IT EXAM - MARCH 2023

HSC IT  March - 2023  EXAM  (Expected Questions) - 10 marks

- 5 marks (Science section)

- 10 marks (Commerce & Arts section)

1. Write a html program to accept Name of the College, Total number of students in the college, Total number of halls (range till 100). The data should be sent to the server.   Watch Video

     College Data

College Information Form

Name of the College :

Total No. of Students :

Total No. of Halls :

2. Write a html program to accept Name of the Employee (cannot be blank), Email Id of the Employee, Salary (maximum 50000). The data should be sent to the server.   Watch Video

     Employee Data

Employee Information Form

Name of the Employee :

Email ID :

Salary  :

3. Write a html program to create a form to accept Doctor's name, number of patients (maximum 20), Date of examining patients. Watch Video

     Hospital Data

Doctor Information Form

Name of the Doctor :

No. of Patients :

Date of Examination :

4. Write a html program to create a form to accept Patient's name, his mobile number and date of birth. Keep all fields compulsory. Watch Video

     Hospital Data

Patient Information Form

Name of the Patient :

Mobile No. :

Date of Birth :

5. Write a html program to create a form to accept student's name, number of practicals he has completed and provide facility to upload his completion certificate.  Watch Video

     Student Data

Student Practical Information Form

Name of the Student :

No. of Practicals Completed :

6. Write a html program to create a form to accept students roll no (in number format), Unit test marks (maximum 25 marks), Terminal exam marks (maximum 50 marks). Include the name of the Subject teacher and send the data to the server.

     Student Data

Student Exam Marks Form

Student Roll No :

Unit Test Marks :

Terminal Exam Marks :

Name of the Subject Teacher :

7. Write a html program to create registration form to accept name, mobile no., date of birth. The form should have register caption in the button to submit the data.

     User Data

User Registration Form

Name of the User :

Mobile No. :

Date of Birth :

8. Write html program to accept Name of the hospital, Email Id of the hospital, Number of beds in the hospital. The data should be sent to the server.

     Hospital Data

Hospital Information Form

Name of the Hospital :

Email Id. :

Number of beds in Hospital :

9.A. Write html program to create a form to accept students roll no (in number format), Unit test marks(maximum 25 marks), Terminal exam marks (maximum 50 marks). Include the name of the Subject teacher and send the data to the server.

     Student Data

Student Exam Marks Form

Student Roll No :

Unit Test Marks :

Terminal Exam Marks :

Name of the Subject Teacher :

9.B. Write html program to accept student name, Date of birth and attendance percentage in number format. Send the data to the server.

     Student Data

Student Attendance Percentage

Student Name :

Date of Birth:

Attendance Percentage  :

10. Write a html program to display "Digital India" in Verdana font using internal CSS. Add any two sentences about Digital India below in orange color. Watch Video

     Digital India

Digital India

Digital India is a campaign launched by the Government of India to ensure that the Government's services are made available to citizens electronically through improved online infrastructure and by increasing Internet connectivity.

It making the country digitally empowered in the field of technology.

11. Write a html program to display "Maharashtra State Board" in blue color and font size 30 pixels using internal CSS. Give background colour yellow for the web page.

     MS Board

Maharashtra State Board

12. Write a html program to display "Maharashtra State Board" in font size 40 pixels using internal CSS. Give background colour yellow for the same text.

     MS Board

Maharashtra State Board

13. Write a html program to display "Web designing" in italic format and having underline using internal CSS. Add any two sentences about web designing in green color.

     Web Designing

Web Designing

Web designing is the art of planning and arranging content on a website so that it can be shared and accessed online with the world.

Web design encompasses many different skills and disciplines in the production and maintenance of websites.

14. Write a html program to insert inline frame on web page. Use xyz html file as a source for inline frame. Size of inline frame should be 100x100 pixels.

     Inline Frame example

Inline Frame

15. Write html program to insert inline frame on web page. Use xyz html file as a source for inline frame. Size of inline frame should be 300 x 300 pixels.

     Inline Frame example

Inline Frame

16. Write html program to create an ordered list of 3 languages used for speaking and unordered list having 2 computer languages. Watch Video

     Languages

Languages used for Speaking

1. English
2.
3. Hindi
4.
5. Marathi
6.

Computer Languages

• Java
•
• Python
•

17. Write html program to display names of two friends in ordered list and also display their hobbies under their name in unordered list. Watch Video

     Friends and their Hobbies

Friends and their Hobbies

1. Vedika
2.

• Singing
•
• Dance
•

3. Riya
4.

•
• Travelling to Historical Places
•

18. Write html program to create an unordered list having names of two students. Add ordered list of subjects they selected:

     Students subjects

Student List with subjects

• Sanika
•

1. IT
2.
3. Maths
4.

• Sachin
•

1. English
2.
3. PT
4.