Page 350 - Web Applications (803) Class 11
P. 350
LAB ACTIVITY Computational Thinking
1. Write JavaScript code to accept a number from the user. Based on the choice ‘S’ or ‘C’ also entered by the user,
calculate and display
i. Square of the number
ii. Cube of the number
2. Write a JavaScript program to find the Armstrong number of 3 digits.
(Note: an Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the
number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.) [CBSE Handbook]
3. Display squares of numbers from 5 to 1.
4. Write a JavaScript program using for loop that will iterate from 0 to 15. For each iteration, it will check if the current
number is odd or even, and display a message on the screen. Sample Output: [CBSE Handbook]
“0 is even”
“1 is odd”
“2 is even”
----------
----------
5. Define 5 variables in a program, giving them different values and display them using the alert( ) method.
6. Factorial of a number means that the given number is multiplied by all the numbers preceding up to that number.
For eg,
5! = 5 x 4 x 3 x 2 x 1 = 120
Write a program in JavaScript to determine the factorial of a given number.
7. Write a Program in JavaScript to determine whether a given number is prime or not.
8. Use the for loop to print the numbers 8, 11, 14, 17, 20, . . . , 83, 86, 89.
348 Touchpad Web Applications-XI

