Javascript Basic Coding Introduction Practice assignments
-
Operators and Expressions
Use console.log() and document.write() to print the following
-
Write a program to print the following output for the given values a=10,b=20
Output expected is:
10+20=30
10-20=-10
10*20=200
10/20=0
10%20=10
-
Write a program to print the following for a given value a=3;
Output expected:
3*1=3
3*2=6
3*3=9
3*4=12
3*5=15
3*6=18
Apply Appropriate operators to get the desired results
-
Given a variable var x = 23. Increment its value by 1.
-
Print the sum of 12 and 23 using the addition operator.
-
Print the difference of 52 and 36 using the subtraction operator.
-
Print the product of 23 and 56 using the multiplication operator.
-
Divide 36 by 5 and print the output by using the division operator.
-
Divide 67 by 4 and print the quotient.
-
Divide 48 by 7 and print the remainder.
-
Print the value of 2 raised to the power of 6.
-
Given var x = “Edupoly” and var y = “Training”. Print “Edupoly Training” in the console.
-
Find the perimeter of a square having each side 4cm.
-
Find the perimeter of a rectangle of length 50cm and breadth 35cm.
-
Find the circumference of a circle of radius 20cm. (Take π = 3.14)
-
Find the area of a square having each side 12cm.
-
Find the area of a rectangle of length 25cm and breadth 16cm.
-
Find the area of a circle of radius 3.75cm.
-
Given the marks of 3 subjects as 67,48 and 74. Print the average marks of the 3 subjects.
-
Given the cost of a product as ₹538.56, add 18% GST to it and print the total cost.
-
Given a variable var x = 48. Decrement its value by 1.
-
Write a script to swap two numbers;
- Write a script to swap two numbers without using 3rd variable
(please use *,%,/ not + and -)
-
Write a program to print the reminder of a division
- Write a program to print the simple interest rate of given P T R values
-
Write a program to print the simple interest rate of given P T R values
-
Write a program to print the max of given two numbers using ternary operator
-
Write a program to print the max of given three numbers using ternary operator
- Find the area of a square for given length of a side
-
Find the area of a square for given length of a side
-
Find the area of a rectangle for given length and breadth
-
Find the area of a triangle for given base and height
-
Check a given number is even or not using ternary operator
-
Check a given number is odd or not using ternary operator
-
Check a given number is positive or not using ternary operator
-
Check a given number is multiple of 4 or not using ternary operator
-
Print the (a+b)^2 for given a and b values
-
Print the (a+b)^3 for given a and b values
-
Print the (a+b+c)^2 for given a,b and c values
-
Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic
salary, and
house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.
-
The distance between two cities (in km.) is input through the keyboard. Write a program to
convert and
print this distance in meters, feet, inches and centimeters.
-
If the marks obtained by a student in five different subjects are input through the keyboard,
find out
the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks
that can
be obtained by a student in each subject is 100.
-
Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to
convert
this temperature into Centigrade degrees.
-
The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write
a
program to calculate the area & perimeter of the rectangle, and the area & circumference of the
circle.
-
Two numbers are input through the keyboard into two locations C and D. Write a program to
interchange
the contents of C and D.
-
If a five-digit number is input through the keyboard, write a program to calculate the sum of
its
digits. (Hint: Use the modulus operator ‘%’)
-
If a five-digit number is input through the keyboard, write a program to reverse the number.
-
If a four-digit number is input through the keyboard, write a program to obtain the sum of the
first and
last digit of this number.
-
In a town, the percentage of men is 52. The percentage of total literacy is 48. If total
percentage of
literate men is 35 of the total population, write a program to find the total number 48 Let Us C
of
illiterate men and women if the population of the town is 80,000.
-
A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is
input
through the keyboard in hundreds, find the total number of currency notes of each denomination
the
cashier will have to give to the withdrawer.
-
If the total selling price of 15 items and the total profit earned on them is input through the
keyboard, write a program to find the cost price of one item.
-
If a five-digit number is input through the keyboard, write a program to print a new number by
adding
one to each of its digits. For example if the number that is input is 12391 then the output
should be
displayed as 23402.
-
Write a program that converts Centigrade to Fahrenheit.
Expected Output :
Input a temperature (in Centigrade): 45
113.000000 degrees Fahrenheit.
-
Write a JavaScript program that calculates the volume of a sphere.
Expected Output :
Input the radius of the sphere : 2.56
The volume of the sphere is 70.276237.
-
Write a JavaScript program that prints the perimeter of a rectangle to take its height and width
as input.
Expected Output :
Input the height of the Rectangle : 5
Input the width of the Rectangle : 7
Perimeter of the Rectangle is : 24.000000
-
Write a JavaScript program that converts kilometers per hour to miles per hour.
Expected Output :
Input kilometers per hour: 15
9.320568 miles per hour
-
Write a JavaScript program that takes hours and minutes as input, and calculates the total
number of minutes.
Expected Output :
Input hours: 5
Input minutes: 37
Total: 337 minutes.
-
Write a program in JavaScript that takes minutes as input, and display the total number of hours
and minutes.
Expected Output :
Input minutes: 546
9 Hours, 6 Minutes
-
Write a program in JavaScript that reads a forename, surname and year of birth and display the
names and the year one after another sequentially.
Expected Output :
Input your firstname: Tom
Input your lastname: Davis
Input your year of birth: 1982
Tom Davis 1982
-
Write a program in JavaScript to calculate the sum of three numbers with getting input in one
line separated by a comma.
Expected Output :
Input three numbers separated by comma : 5,10,15
The sum of three numbers : 30
-
Write a JavaScript program to perform addition, subtraction, multiplication and division of two
numbers
Expected Output :
Input any two numbers separated by comma : 10,5
The sum of the given numbers : 15
The difference of the given numbers : 5
The product of the given numbers : 50
The quotient of the given numbers : 2.000000
-
Write a JavaScript program to find the third angle of a triangle if two angles are given.
Expected Output :
Input two angles of triangle separated by comma : 50,70
Third angle of the triangle : 60
-
Write a script to display the maximum number in given two numbers using operators
-
Write a script to display the maximum number in given three numbers using operators
-
Write a script to display the given two strings in ascending order using operators
-
Worksheet on Expressions(download and open in ms-word or googledocs and work on it)
Expressions Worksheet