JAVA SCRIPT TASKS
TASK:1 Write a program to Swap two Variables a and b (Swapping basically means interchanging)
Input
a=3 , b=4
Output
a=4, b=3
TASK:2 Write a program to print the largest number of the two numbers given.
Input:-
a=3, b=4
Output:
4
TASK:3 Write a program to print the largest of the three numbers.
Input:-
a=3, b=5, c=1
Output:-
5
IF-ELSE-IF ladder
TASK:4 Given a variable D (distance) write a program to print the cost associated with it as shown in the image:-
Input:-
D = 700
Output:-
10
Ternary Operators - 1
TASK:5 Write a program to assume a value of marks and print whether a person has failed or passed using ternary Operator.
If Marks> =40 --> pass
ELSE ---> fail
Input:-
Marks =52
Ouput:-
pass
Ternary Operator -2
TASK:6 Write a program to print the maximum of two numbers using Ternary operator.
Input:-
a=3, b=5
Output:-
5
Switch -1
TASK:6 Given the Day number, print the Day name in lower case corresponding to it by using the help of switch statement.
Note: Day 1 - is monday.
If the day is not valid example 1> day >7 then print invalid
Input :-
Day - 3
Output :-
wednesday
Switch -2
What will be the output of the following algorithm .
switch (x)
{
case 1:
print( "Choice is 1");
break;
case 2:
print( "Choice is 2");
case 3:
print("Choice is 3");
case 4:
print("Choice is 4");
break;
default:
print("Choice other than 1, 2, 3 and 4")
break;
}
Which of the following Option is correct if (x=2) :-
A) Choice is 1
B) Choice is 1
Choice is 2
C) Choice is 2
Choice is 3
Choice is 4
D) Choice is 2
Choice is 3
No comments:
Post a Comment