To create an html file and to display the various arithmetic operations on variables using javascript.

Source Code:

<!DOCTYPE html>
<html>
<head>
<title>js2</title>
</head>
<body>
  <b>Below Calculations are performed using Javascript Arithmetic Operations</b>
<center>
  <script type="text/javascript">
var a = 33;
var b = 10;
var c = 56;
var linebreak = "<br />";

document.write("a = " +a);
document.write(linebreak);
document.write("b = " +b);
document.write(linebreak);
document.write("a + b = ");
result = a + b;
document.write(result);
document.write(linebreak);

document.write("a - b = ");
result = a - b;
document.write(result);
document.write(linebreak);

document.write("a / b = ");
result = a / b;
document.write(result);
document.write(linebreak);

document.write("a % b = ");
result = a % b;
document.write(result);
document.write(linebreak);

document.write("a + b + c = ");
result = a + b + c;
document.write(result);
document.write(linebreak);

a = a++;
document.write("a++ = ");
result = a++;
document.write(result);
document.write(linebreak);

b = b--;
document.write("b-- = ");
result = b--;
document.write(result);
document.write(linebreak);
</script>
  </center>
<hr>
    <a href="mailto:sanjam531@gmail.com">Sanjampreet Singh</a>
    <br>
    <a href="http://sanjamhelping.blogspot.in/p/it-14304-it-methodologies-lab.html">Department Of Information Technology</a>
    <br>
    <a href="E:\documents\IM LAB\html\js1\js1.html"><-Last Practical</a>&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="E:\documents\IM LAB\html\js3\js3.html">Next Practical-></a>
    <br>
</body>
</html>

Output:



Include the following source Code in Document Environment in your LaTeX File

LaTeX Source:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{multicol}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{transparent}
\usepackage{multirow}
\usepackage{eso-pic}
\usepackage[utf8]{inputenc}
\usepackage{color}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\BackgroundIm{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{
\vfill
\centering
{\transparent{0.05} \includegraphics[height=\paperheight,width=\paperwidth,
keepaspectratio]{gne}
\vfill
}}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\AddToShipoutPicture{\BackgroundIm}
\newpage
\section{\emph{To create an html file and to display the various arithmetic operations on variables using javascript.}}
\subsection{\emph{Source Code:}}
\begin{verbatim}
<!DOCTYPE html>
<html><head>
<title>js2</title>
</head> <body>
<b>Below Calculations are performed using Javascript Arithmetic Operations</b>
<center>
<script type="text/javascript">
var a = 33; var b = 10; var c = 56;
var linebreak = "<br />";
document.write("a = " +a);
document.write(linebreak);
document.write("b = " +b);
document.write(linebreak);
document.write("a + b = ");
result = a + b;
document.write(result);
document.write(linebreak);
document.write("a - b = ");
result = a - b;
document.write(result);
document.write(linebreak);
document.write("a / b = ");
result = a / b;
document.write(result);
document.write(linebreak);
document.write("a % b = ");
result = a % b;
document.write(result);
document.write(linebreak);
document.write("a + b + c = ");
result = a + b + c;
document.write(result);
document.write(linebreak);
a = a++;
document.write("a++ = ");
result = a++;
document.write(result);
document.write(linebreak);
b = b--;
document.write("b-- = ");
result = b--;
document.write(result);
document.write(linebreak);
</script> </center>
</body><hr>
<a href="mailto:sanjam531@gmail.com">Sanjampreet Singh</a><br>
<a href="http://sanjamhelping.blogspot.in/p/it-14304-it-
methodologies-lab.html">Department Of Information Technology</a><br>
<a href="E:\documents\IM LAB\html\js1\js1.html"><-Last Practical</a>
<a href="E:\documents\IM LAB\html\js3\js3.html">Next Practical-></a><br>
</html>
\end{verbatim}
\subsubsection{\emph{Output:}}
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{js2}
\caption{Output Of HTML page with Js}
\end{figure}
\end{document}

Output:

Comments

Popular posts from this blog

To implement the various components of HTML5 Canvas

Program to illustrate the concept of templates.

Program to illustrate the order of execution of constructors and destructors in inheritance.