0% found this document useful (0 votes)
12 views

CSS - Practical 1

Uploaded by

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

CSS - Practical 1

Uploaded by

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

CSS- PRACTICAL 1

Name:- Anas Qureshi


Roll No:- 220440
---------------------------------------------------------------------------------------------------------------------------
Q1. Write a program to print “Hello World”.
Code:-
<html>
<head>
<title>Anas Qureshi-220440</title>
<script>
document.write("Hello World!!")
</script>
</head>
<body>
</body>
</html>
Output:-

Q2. Write a program to take the user’s name as input and print it.
Code:-
<html>
<head>
<title>Anas Qureshi-220440</title>
<script>
let name=prompt("Enter The Name")
document.write("Your name is "+name)
</script>
</head>
<body>
</body>
</html>
Output:-

Q3. Write a program for arithmetic expression evaluation and message printing.
Code:-
<html>
<head>
<title>Anas Qureshi-220440</title>
<script>
let num1=Number.parseFloat(prompt("Enter the number 1"))
let num2=Number.parseFloat(prompt("Enter the number 2"))
alert("Addition of "+num1+" and "+num2+" = "+(num1+num2))
alert("Subtraction of "+num1+" and "+num2+" = "+(num1-num2))
alert("Multiplication of "+num1+" and "+num2+" = "+(num1*num2))
alert("Division of "+num1+" and "+num2+" = "+(num1/num2))
</script>
</head>
<body>
</body>
</html>
Output:-
Q4. Program to demonstrate getter and setter.
Code: -
<html>
<head>
<title>Anas Qureshi-220440</title>
<script>
document.write("Anas Qureshi-220440 <br><hr>")
const person = {
firstName: "Anas",
lastName: "Qureshi",
get fullName() {
return `${this.firstName} ${this.lastName}`
},
set fullName(name) {
const parts = name.split(" ")
this.firstName = parts[0]
this.lastName = parts[1]
},
};
document.write("First Name:- "+person.firstName + "<br>")
document.write("Last Name:- "+person.lastName+"<br>")
document.write("Full Name:-"+person.fullName)
</script>
</head>
<body>
</body>
</html>

Output: -

You might also like