0% found this document useful (0 votes)
48 views

Computer Assignment 1.odt

This document provides algorithms and flowcharts for several mathematical operations: 1) Summing two numbers 2) Determining if a number is positive or negative 3) Determining if a number is even or odd 4) Finding the greatest of three numbers 5) Calculating the sum of the first n natural numbers 6) Computing the factorial of a given number 7) Summing the even numbers in a set of 20 numbers 8) Finding all divisors of a given number 9) Determining if a number is prime For each operation, it lists the step-by-step process in pseudocode.

Uploaded by

Sobit Shrestha
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Computer Assignment 1.odt

This document provides algorithms and flowcharts for several mathematical operations: 1) Summing two numbers 2) Determining if a number is positive or negative 3) Determining if a number is even or odd 4) Finding the greatest of three numbers 5) Calculating the sum of the first n natural numbers 6) Computing the factorial of a given number 7) Summing the even numbers in a set of 20 numbers 8) Finding all divisors of a given number 9) Determining if a number is prime For each operation, it lists the step-by-step process in pseudocode.

Uploaded by

Sobit Shrestha
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 10

Introduction To Information

Technology

Prepared by: Sobit Shrestha

Roll no: 16

BscCSIT 2079
1
1. Write an algorithm and flowchart to display Sum of two numbers.

Step1 : Start.
Step2 : Input two number a and b.
Step3 : Sum=a+b;
Step4 : Display sum.
Step5 : End.

1
2. Write an algorithm and flowchart to display if the number is positive or negative.

Step1 : Start
Step2: Input number n.
Step3: If n is less than 0 , display n is negative
Else display n is positive.
Step4: End.
3. Write an algorithm and flowchart to display whether the number is even or odd.

Step1: Start.
Step2: Input number n.
Step3: If n%2==0 then display n is even
Else display n is negative.
Step4: End.
4. Write an algorithm and flowchart to read three numbers and print the greatest number.

Step1: Start.
Step2: Input three numbers a,b and c.
Step3: If a >b & a>c, display a is the greatest number.
Else go to step 4.
Step4: If b>c ,display b is the greatest number.
Else display c is the greatest number.
Step5: End.
5. Write an algorithm and flowchart to find the sum of the series 1+2+3+4..... Up to entered n numbers.

Step1: Start.
Step2: Input number n.
Step3: Initialize i=1, sum =0, If i=<n;
sum =sum +i;
Else go to step 6.
Step4: i=i+1; ,Go to step 3.
Step5: Display sum.
Step6: End.

6. Write an algorithm and flowchart to display factorial of a given number N.


Step1: Start.
Step2: Input number n.
Step3: Initialize i=1, fact =0, If i=<n;
fact = fact*i;
Else go to step 6.
Step4: i=i+1; ,Go to step 3.
Step5: Display fact.
Step6: End.

7. Write an algorithm and flowchart


to read first 20 number and display
only sum of even numbers.
Step1: Start.
Step2: Input 20 number .
Step3: Initialize i=1

8. Write an algorithm and flowchart to read a number n and display all of its divisors.
Step1: Start.
Step2: Input number n.
Step3: Initialize i=1, if I<=n go to step 4
Else go to step 6.
Step4: If n%==0 then print “I is divisor”
Else ignore.
Step5: i=i+1, go to step 3.
Step6: End.

9. Write an algorithm and flowchart which display if number is prime or not.


Step1: Start.
Step2: Input the number n.
Step3: Initialize i=2, if i>n go to step4 else go to step5.
Step4: If n%i!=0 then I =i+1,and go to step 3
Else display “n is not prime number.” and go to step6.
Step5: Print “n is prime number”
Step6: End.

You might also like