| Operators | Description | Examples |
|---|---|---|
| + | Addition | if a=6, b=3; a+b = 9 |
| - | Subtraction | if a=6, b=3; a-b = 3 |
| * | Multiplication | if a=6, b=3; a*b = 18 |
| / | Division | if a=6, b=3; a/b = 2 |
| % | Modulus | if a=6, b=3; a%b = 0 |
| ++ | Increment | if a=6; a++ = 6 ++a =7 |
| -- | Decrement | if a=6; a-- = 6 --a =5 |
Addition(+) Arithmetic Operator
Operands को add करने के लिए इस operator का use किया जाता हैं|
Q :- Addition(+) Arithmetic Operator in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Addition(+) Arithmetic Operator</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,add=0;
a=prompt("Enter a Number",6);
b=prompt("Enter b Number",3);
a=parseInt(a);
b=parseInt(b);
add=a+b;
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("Addition : "+add);
</script>
</body>
</html>
Output :-
a : 6 b : 3 Addition : 9
Subtraction(-) Arithmetic Operator
Operands को subtract करने के लिए इस operator का use किया जाता हैं|
Q :- Subtraction(-) Arithmetic Operator in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Subtraction(-) Arithmetic Operator</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,sub=0;
a=prompt("Enter a Number",6);
b=prompt("Enter b Number",3);
a=parseInt(a);
b=parseInt(b);
sub=a-b;
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("Subtraction : "+sub);
</script>
</body>
</html>
Output :-
a : 6 b : 3 Subtraction : 3
Multiplication(*) Arithmetic Operator
Operands को multiply करने के लिए इस operator का use किया जाता हैं|
Q :- Multiplication(*) Arithmetic Operator in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Multiplication(*) Arithmetic Operator</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,mul=0;
a=prompt("Enter a Number",6);
b=prompt("Enter b Number",3);
a=parseInt(a);
b=parseInt(b);
mul=a*b;
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("Multiplication : "+mul);
</script>
</body>
</html>
Output :-
a : 6 b : 3 Multiplication : 18
Division(/) Arithmetic Operator
Operands को divide करने के लिए इस operator का use किया जाता हैं|
Q :- Division(/) Arithmetic Operator in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Division(/) Arithmetic Operator</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,div=0;
a=prompt("Enter a Number",6);
b=prompt("Enter b Number",3);
a=parseInt(a);
b=parseInt(b);
div=a/b;
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("Division : "+div);
</script>
</body>
</html>
Output :-
a : 6 b : 3 Division : 2
Modulus(%) Arithmetic Operator
दो operands से remainder निकालने के लिए इस operator का use किया जाता हैं|
Q :- Modulus(%) Arithmetic Operator in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Modulus(%) Arithmetic Operator</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,mod=0;
a=prompt("Enter a Number",6);
b=prompt("Enter b Number",3);
a=parseInt(a);
b=parseInt(b);
mod=a%b;
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("Modulus : "+mod);
</script>
</body>
</html>
Output :-
a : 6 b : 3 Modulus : 0
Increment(++) Arithmetic Operator
Operands को एक से बढाने के लिए इस operator का use किया जाता हैं|
Q :- Write a program to extract a prefix increment in JavaScript by entering a number.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>(++)Prefix Increment</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0;
a=prompt("Enter a Number",6);
a=parseInt(a);
b=++a; // Prefix Increment
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
</script>
</body>
</html>
Output :-
a : 7 b : 7
Q : Write a program to extract a postfix increment in JavaScript by entering a number.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Postfix Increment(++)</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0;
a=prompt("Enter a Number",6);
a=parseInt(a);
b=a++; // Postfix Increment(++)
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
</script>
</body>
</html>
Output :-
a : 7 b : 6
Decrement(--) Arithmetic Operator
Operands को एक से घटने के लिए इस operator का use किया जाता हैं|
Q : Write a program to extract a prefix decrement in JavaScript by entering a number.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>(--)Prefix Decrement</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0;
a=prompt("Enter a Number",6);
a=parseInt(a);
b=--a; // (--)Prefix Decrement
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
</script>
</body>
</html>
Output :-
a : 5 b : 5
Q : Write a program to extract a postfix decrement in JavaScript by entering a number.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Postfix Decrement(--)</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0;
a=prompt("Enter a Number",6);
a=parseInt(a);
b=a--; // Postfix Decrement(--)
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
</script>
</body>
</html>
Output :-
a : 5 b : 6
Q : Increment and Decrement Program in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Increment and Decrement</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,c=0;
a=prompt("Enter a Number",6);
b=prompt("Enter b Number",7);
a=parseInt(a);
b=parseInt(b);
c=(++a)*(b--);
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("c : "+c+"<br>");
</script>
</body>
</html>
Output :-
a : 7 b : 6 c : 49
Q :- Increment and Decrement Program in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Increment and Decrement</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,c=0;
a=prompt("Enter a Number",5);
b=prompt("Enter b Number",6);
a=parseInt(a);
b=parseInt(b);
c=(++a)+(a--)+(++b)+(b--);
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("c : "+c+"<br>");
</script>
</body>
</html>
Output :-
a : 6 b : 5 c : 26
Q :- Increment and Decrement Program in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Increment and Decrement</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,c=0;
a=prompt("Enter a Number",5);
b=prompt("Enter b Number",6);
a=parseInt(a);
b=parseInt(b);
c=[(++a)*(--b)]*[(a--)*(b--)];
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("c : "+c+"<br>");
</script>
</body>
</html>
Output :-
a : 5 b : 4 c : 900
Q :- Increment and Decrement Program in JavaScript.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Increment and Decrement</title>
</head>
<body>
<script type="text/javascript">var a=0,b=0,c=0,d=0;
a=prompt("Enter a Number",5);
b=prompt("Enter b Number",6);
c=prompt("Enter c Number",7);
a=parseInt(a);
b=parseInt(b);
c=parseInt(c);
d=[(++a)*(++b)+(++c)]*[(a--)*(b--)*(c--)];
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("c : "+c+"<br>");
document.write("d : "+d+"<br>");
</script>
</body>
</html>
Output :-
a : 5 b : 6 c : 7 d : 16800
Q:- Write a JavaScript program in enter the five number and find the average.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Average Number</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,c=0,d=0,e=0,sum=0,avg=0;
a=prompt("Enter a Number",5);
b=prompt("Enter b Number",6);
c=prompt("Enter c Number",7);
d=prompt("Enter d Number",8);
e=prompt("Enter e Number",9);
a=parseInt(a);
b=parseInt(b);
c=parseInt(c);
d=parseInt(d);
e=parseInt(e);
sum=a+b+c+d+e;
avg=sum/5;
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
document.write("c : "+c+"<br>");
document.write("d : "+d+"<br>");
document.write("e : "+e+"<br>");
document.write("average : "+avg+"<br>");
</script>
</body>
</html>
Output :-
a : 5 b : 6 c : 7 d : 8 e : 9 average : 7
Q :- Write a JavaScript Program with Variable.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>with Variable</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0,c=0;
a=prompt("Enter a Number",5);
b=prompt("Enter b Number",6);
a=parseInt(a);
b=parseInt(b);
c=a+b;
b=c-b;
a=c-b;
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
</script>
</body>
</html>
Output :-
a : 6 b : 5
Q :- Write a JavaScript program to change the value of a and b without the help of variable.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>without Variable</title>
</head>
<body>
<script type="text/javascript">
var a=0,b=0;
a=prompt("Enter a Number",5);
b=prompt("Enter b Number",6);
a=parseInt(a);
b=parseInt(b);
a=b-a;
b=b-a;
a=b+a;
document.write("a : "+a+"<br>");
document.write("b : "+b+"<br>");
</script>
</body>
</html>
Output :-
a : 6 b : 5
Q :- Write a JavaScript Program to input the length and with of the rectangle and print its area.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>rectangle area</title>
</head>
<body>
<script type="text/javascript">
var l=0,w=0,area=0;
l=prompt("Enter Length Value",5);
w=prompt("Enter Width Value",6);
l=parseInt(l);
w=parseInt(w);
area=l*w;
document.write("Length : "+l+"<br>");
document.write("Width : "+w+"<br>");
document.write("Area : "+area);
</script>
</body>
</html>
Output :-
Length : 5 Width : 6 Area : 30
Q :- Write a JavaScript Program to input the radius of the circle and print its area.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>circle area</title>
</head>
<body>
<script type="text/javascript">
var r=0,area=0;
r=prompt("Enter Radius Value",5);
r=parseFloat(r);
area=22/7*r*r;
document.write("Radius : "+r+"<br>");
document.write("Area : "+area);
</script>
</body>
</html>
Output :-
Radius : 5 Area : 78.571
Q :- Write a JavaScript Program to input the Principal Rate and Time and extract its Simple Intrest.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Simple Intrest</title>
</head>
<body>
<script type="text/javascript">
var p=0,r=0,t=0,si=0;
p=window.prompt("Enter Principal Amount",5000);
r=window.prompt("Enter Rate",5);
t=window.prompt("Enter Time",2);
p=parseInt(p);
r=parseInt(r);
t=parseInt(t);
si=p*r*t/100;
document.write("Principal : "+p+"Rs"+"<br>");
document.write("Rate : "+r+"%"+"<br>");
document.write("Time : "+t+"Year"+"<br>");
document.write("Simple Intrest : "+si+"Rs");
</script>
</body>
</html>
Output :-
Principal : 5000Rs Rate : 5% Time : 2Year Simple Intrest : 500Rs
Q : Write a JavaScript Program to convert fahrenheit to celsius.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>fahrenheit to celsius</title>
</head>
<body>
<script type="text/javascript">
var f=0,c=0;
f=window.prompt("Enter Fahrenheit Value",32);
f=parseFloat(f);
c=[(f-32)*5]/9;
document.write("Fahrenheit : "+f+"<br>");
document.write("Celsius : "+c);
</script>
</body>
</html>
Output :-
Fahrenheit : 32 Celsius : 0
Q :- Write a JavaScript Program to convert celsius to fahrenheit.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>celsius to fahrenheit</title>
</head>
<body>
<script type="text/javascript">
var f=0,c=0;
c=window.prompt("Enter Celsius Value",0);
c=parseFloat(c);
f=(9*c)/5+32;
document.write("Celsius : "+c+"<br>");
document.write("Fahrenheit : "+f);
</script>
</body>
</html>
Output :-
Celsius : 0 Fahrenheit : 32
Q :- Write a JavaScript program to extract the student's total marks and percentage by inputting the student's name and subjects' marks.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Marksheet</title>
</head>
<body>
<script type="text/javascript">
var name,m=0,h=0,s=0,sst=0,e=0,san=0,tm=0,per=0;
name=window.prompt("Enter Your Name","Amit");
m=window.prompt("Enter Your Math Marks",85);
h=window.prompt("Enter Your Hindi Marks",90);
s=window.prompt("Enter Your Science Marks",70);
sst=window.prompt("Enter Your Sco.Science Marks",80);
e=window.prompt("Enter Your English Marks",78);
san=window.prompt("Enter Your Sanskrit Marks",75);
m=parseInt(m);
h=parseInt(h);
s=parseInt(s);
sst=parseInt(sst);
e=parseInt(e);
san=parseInt(san);
tm=m+h+s+sst+e+san;
per=tm/6;
document.write("Name : "+name+"<br>");
document.write("Math : "+m+"<br>");
document.write("Science : "+s+"<br>");
document.write("Sco.Science : "+sst+"<br>");
document.write("Hindi : "+h+"<br>");
document.write("English : "+e+"<br>");
document.write("Sanskrit : "+san+"<br>");
document.write("Total Marks : "+tm+"<br>");
document.write("Percentage : "+per+"%"+"<br>");
</script>
</body>
</html>
Output :-
Name : Amit Math : 85 Science : 70 Sco.Science : 80 Hindi : 90 English : 78 Sanskrit : 75 Total Marks : 478 Percentage : 79.67%
Q :- Write a JavaScript program to make a Salary Statement.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Salary Statement</title>
</head>
<body>
<script type="text/javascript">
var ei,en,bs=0,da=0,hra=0,pf=0,gs=0,epf=0,lic=0,td=0,ns=0;
ei=window.prompt("Enter Your Employee Id",101);
en=window.prompt("Enter Your Employee Name","Amit");
bs=window.prompt("Enter Your Basic Salary",5000);
bs=parseInt(bs);
da=bs*10/100;
hra=bs*7.5/100;
pf=bs*15/100;
gs=da+hra+pf+bs;
epf=pf/2;
lic=epf/2;
td=epf+lic;
ns=gs-td;
document.write("Employee Id : "+ei+"<br>");
document.write("Employee Name : "+en+"<br>");
document.write("Basic Salary : "+bs+"<br>");
document.write("Dearness Allowance : "+da+"<br>");
document.write("House Rent Allowance : "+hra+"<br>");
document.write("Provident fund : "+pf+"<br>");
document.write("Gross Salary : "+gs+"<br>");
document.write("Employee Provident fund : "+epf+"<br>");
document.write("Life Insurance Corporation : "+lic+"<br>");
document.write("Total Deduction : "+td+"<br>");
document.write("Net Salary : "+ns);
</script>
</body>
</html>
Output :-
Employee Id : 101 Employee Name : Amit Basic Salary : 5000 Dearness Allowance : 500 House Rent Allowance : 375 Provident fund : 750 Gross Salary : 6625 Employee Provident fund : 375 Life Insurance Corporation : 187.5 Total Deduction : 562.5 Net Salary : 6062.5
Post a Comment
If you have any doubts,Please let me know