Use the “%” operator in the if block to get the type of number.
Print num1 is the largest if num1 > num2 else Print num2 is the largest if num1 < num2. On none true condition print num1 and num2 are equal.
In the entry we were given 3 numbers. You must order these numbers from smallest to largest using conditional operators
- If month is outside the range of 1 and 12 print “Invalid month”.
- If month is equal to 2 ie, February print “29 days” if leap year else print “28 days” .
- Else if month is equal to 4, 6, 9 or 11 print “30 days”.
- Else print “31 days”.
- Print “S grade” if marks is between 90 and 100.
- Print “A grade” if marks is between 80 and 90.
- Print “B grade” if marks is between 70 and 80.
- Print “C grade” if marks is between 60 and 70.
- Print “D grade” if marks is between 50 and 60.
- Print “E grade” if marks is between 40 and 50.
- Print “Student has failed” if marks is between 0 and 40.
- Else print “Invalid marks”.
- If year is divisble by 4 and not divisble by 100 then print “leap year”.
- Or if year is divisible by 400 then print “leap year”.
- Else print “not a leap year”.
2012 //"Year 2012 is a leap year"
1900 //"Year 1900 is not a leap year"
2000 //"Year 2000 is a leap year"
2011 //"Year 2011 is not a leap year"
Create 3 variables. Let them be num1, num2 and op. num1 and num2 are our numbers. and op is any arithmetic operator. For example, multiply, divide, subtract, add, modulus
- Print result of num1+num2 if operation is “add”
- Print result of num1-num2 if operation is “subtract”
- Print result of num1*num2 if operation is “multiply”
- Print result of num1/num2 if operation is “divide”
- Print result of num1%num2 if operation is “modulus”
- Else print “Invalid operation”
Create three variables named side1, side2, side3. These variables are the sides of the triangle and simply accept numbers. Find the type of triangle using the “==” and “&&” operators in JavaScript.
- Print “Equilateral triangle.” if values for all side1, side2 and side3 are equal.
- Print “Isosceles triangle.” if values for side1 is equal to side2 or side2 is equal to side3
- Else “Scalene triangle.” since values of all sides are unequal.