• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 42 pages
Exam (elaborations)

CSS Practical exam Answers 2025

Document preview thumbnail
Preview 4 out of 42 pages

CSS Practical exam Answers 2025

Content preview

lOMoAR cPSD| 46020670




CSS Practical exam Answers 2025

1. Write a program to execute the conditional operator(ternary) in JavaScript.

Ans: <html>
<head>

<title>Even or Odd Checker</title>

</head>
<body>



<script>

// Ask the user to enter a number var number =

prompt("Enter a number:");



// Check if the number is even or odd using the ternary operator var result =

(number % 2 === 0) ? "Even" : "Odd";



// Display the result using an alert box

alert("The number " + number + " is " + result + "."); </script>



</body>

</html>
2. Write a JavaScript program to print the factorial of a given number.

Ans: <html>

<head>

<title>Factorial Calculator</title>

</head>
<body>

, lOMoAR cPSD| 46020670




<script>
// Ask the user to enter a number
var number = prompt("Enter a number to calculate its factorial:");



// Convert the input to a number number =

parseInt(number);



// Function to calculate factorial function

factorial(n) { if (n === 0 || n === 1) { return

1; // Base case: 0! and 1! are 1

}

return n * factorial(n - 1); // Recursive case }



// Calculate the factorial of the given number var result =

factorial(number);



// Display the result using document.write

document.write("The factorial of " + number + " is " + result + "."); </script>



</body>
</html>



3. Write a JavaScript program to print the Fibonacci series till 10 number.
Ans: simple one:

<html>

<head>

<title>Fibonacci Series</title>

</head>
<body>

, lOMoAR cPSD| 46020670




<script>
var n = 10; // Number of terms
var a = 0, b = 1, next; // Initialize the first two numbers



document.write("Fibonacci series up to 10 numbers: ");



for (var i = 1; i <= n; i++) {

document.write(a + " "); // Print the current number next = a

+ b; // Calculate the next number a = b; // Update 'a' to the next

number b = next; // Update 'b' to the next number

}
</script>



</body>
</html>



User input one:



<html>
<head>

<title>Fibonacci Series</title>

</head>

<body>

<script>
// Take user input for the number of terms

var n = prompt("Enter the number of terms for the Fibonacci series:"); n = parseInt(n);

// Convert input to a number



var a = 0, b = 1, next; // Initialize the first two numbers

, lOMoAR cPSD| 46020670




document.write("Fibonacci series up to " + n + " numbers: ");



for (var i = 1; i <= n; i++) {

document.write(a + " "); // Print the current number next = a

+ b; // Calculate the next number a = b; // Update 'a' to the next

number b = next; // Update 'b' to the next number

}
</script>



</body>

</html>

4. Write a code to find out whether the year is leap year or not.

Ans: simple one:

<html>
<head>

<title>Leap Year Checker</title>

</head>
<body>



<script>

// Prompt the user to enter a year

var year = prompt("Enter a year to check if it is a leap year:"); year =

parseInt(year); // Convert the input to an integer



// Check if the year is a leap year

if ((year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0)) { alert(year + " is a leap

year.");

} else {
alert(year + " is not a leap year.");

Document information

Uploaded on
March 5, 2025
Number of pages
42
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$28.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
GoldStar
4.7
(269)
Sold
315
Followers
14
Items
996
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions