• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 42 páginas
Examen

CSS Practical exam Answers 2025

Document preview thumbnail
Vista previa 4 fuera de 42 páginas

CSS Practical exam Answers 2025

Vista previa del contenido

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.");

Información del documento

Subido en
5 de marzo de 2025
Número de páginas
42
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$28.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
GoldStar
4.7
(270)
Vendido
317
Seguidores
14
Artículos
1011
Última venta
2 semanas hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes