<head>
<script>
// Function With both Arguments and return type
function clac(x, s, y) // called function
{
switch(s)
{
case '+': return(x+y); break;
case '-': return(x-y); break;
case '*': return(x*y); break;
case '/': return(x/y); break;
case '%': return(x%y); break;
}
}
</script>
</head>
<body>
<script>
line1();
res=clac(5, '*', 80); // calling function
document.write("<br/>Res="+ res);
line('$', 50);
document.write("<br/>ANs=" + clac(52, '/', 3));
</script>
</body>
output:
Res=400
ANs=17.333333333333332
<script>
// Function With both Arguments and return type
function clac(x, s, y) // called function
{
switch(s)
{
case '+': return(x+y); break;
case '-': return(x-y); break;
case '*': return(x*y); break;
case '/': return(x/y); break;
case '%': return(x%y); break;
}
}
</script>
</head>
<body>
<script>
line1();
res=clac(5, '*', 80); // calling function
document.write("<br/>Res="+ res);
line('$', 50);
document.write("<br/>ANs=" + clac(52, '/', 3));
</script>
</body>
output:
Res=400
ANs=17.333333333333332
No comments:
Post a Comment