To demonstrate the use of control statements and loops in javascript.

Finding Armstrong Number

Source Code:

<!DOCTYPE html>
<html>
<head>
<title>JS6</title>
</head>
<body>
<hr>
<a href="E:\documents\IM LAB\html\html3-mail link.html">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\js5\js5.html"><-Last Practical</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="E:\documents\IM LAB\html\js7\js7.html">Next Practical-></a>
<br>
<script>
var b,z,c=0;
var a=prompt("Enter a number");
z=a;
while(z>0)
{
b=z%10;
c=c+(b*b*b);
z=parseInt(z/10);
}
if(a==c)
alert("given no is amstrong number");
else
alert("given no is not an amstrong number");
</script>
</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 demonstrate the use of control statements and loops in javascript.}}
\subsection{\emph{Source Code:}}
\begin{verbatim}
<!DOCTYPE html>
<html>
<head><title>JS6</title></head>
<body>
<a href="E:\documents\IM LAB\html\html3-mail 
link.html">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\js5\js5.html"><-Last Practical</a>
<a href="E:\documents\IM LAB\html\js7\js7.html">Next Practical-></a><br>
<script>
var b,z,c=0;var a=prompt("Enter a number");
z=a;while(z>0)
{b=z%10;
c=c+(b*b*b);
z=parseInt(z/10);}
if(a==c)alert("given no is amstrong number");
elsealert("given no is not an amstrong number");
</script></body>
</html>
\end{verbatim}
\subsubsection{\emph{Output:}}
\begin{figure}[h]
\centering
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.35]{js6-1}
\caption{a}
\end{subfigure}
~
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.36]{js6-2}
\caption{b}
\end{subfigure}
\caption{Output Of HTML page with Js}
\end{figure}
\end{document}

Output:


Comments

Popular posts from this blog

Program to illustrate the concept of templates.

To create an html file to implement the concept of margin, padding using cascading style sheets.

To configure the IP address for a computer connected to LAN