0% found this document useful (0 votes)
28 views4 pages

Assignment Number: 8 Roll Number: 38

This document contains the source code and output for 4 questions from a programming assignment. Question 1 asks to write a program to calculate the sum of digits in a number. Question 2 asks to check if a number is prime. Question 3 displays the multiplication table from 1 to 10. Question 4 displays a pattern of increasing then decreasing asterisks. The source code for each question is provided in HTML along with the expected output.

Uploaded by

Tasleem Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views4 pages

Assignment Number: 8 Roll Number: 38

This document contains the source code and output for 4 questions from a programming assignment. Question 1 asks to write a program to calculate the sum of digits in a number. Question 2 asks to check if a number is prime. Question 3 displays the multiplication table from 1 to 10. Question 4 displays a pattern of increasing then decreasing asterisks. The source code for each question is provided in HTML along with the expected output.

Uploaded by

Tasleem Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment Number: 8 Roll Number: 38

QUESTION NUMBER 1:- Write A program to display sum of digit of given number.

SOURCE CODE:-
<HTML>
<Head>
<Title>Assignment Number 8 q1</Title>
</Head>
<Body>
<script>
var a=prompt("Enter a digit");
var sum=0;
while(a>0)
{
sum=sum+a%10;
a=Math.floor(a/10);
}
document.write("Sum of digits "+sum);
</script>
</HTML>
OUTPUT:-

Page Number:-
Assignment Number: 8 Roll Number: 38
QUESTION NUMBER 2:- Write a program to check given number is Prime or Not.

SOURCE CODE:-
<Html>
<Head>
<Title>Assignment Number 8 q2</Title>
</Head>
<Body>
<script>
var number=prompt("Enter a Number");
var i,flag=0;
number = Number(number.value);
for(i=2; i <= number/2; i++)
{
if(number%i == 0)
{
flag = 1;
break;
}
}
if(flag == 0)
{
document.write("The inputed number is Prime");
}
else
{
document.write("The inputted number is not Prime");
}

</script>
</Body>
</Html>
OUTPUT:-

Page Number:-
Assignment Number: 8 Roll Number: 38
QUESTION NUMBER 3:- Write a program to display multiplication table from 1 to 10

SOURCE CODE:-

<html>
<head>
<title>Assignment Number 8 q3</Title>
</Head>
<Body>
<script Language="Javascript">
var i,j;
document.write("Display Multiplication Table Of 1 to 10<br>");
for(i=1;i<=10;i++)
{
for(j=1;j<=10;j++)
{
document.write(i*j+" ");
}
document.write("<br><br>");
}
</script>
</Body>
</Html>

OUTPUT:-

Page Number:-
Assignment Number: 8 Roll Number: 38
QUESTION NUMBER 4:- Display Following pattern.
*
**
***
****
*****
******
*****
****
***
**
*

SOURCE CODE:-

<html>
<Head>
<Title>Assignment number 8 q4</Title>
</Head>
<Body>
<Script Language="Javascript">
var i,j;
for(i=0;i<=5;i++)
{
for(j=0;j<=i;j++)
{
document.write('*');
}
document.write('<br>')
}
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
document.write('*');
}
document.write('<br/>');
}
</Script>
</Body>
</Html>

OUTPUT:-

Page Number:-

You might also like