1. Design an algorithm and the corresponding flowchart for finding the sum of
the numbers 2, 4, 6, 8, …, n
2. Using flowcharts, write an algorithm to read 100 numbers and then display the
sum.
3. Write an algorithm to read two numbers then display the largest.
4. Write an algorithm to read two numbers then display the smallest
5. Write an algorithm to read three numbers then display the largest.
6. Write an algorithm to read 100 numbers then display the largest.
Q1
Declare Integer n
Declare Integer i
Declare Integer sum
Display "Ente N: "
Input n
Set sum = 0
Set i = 2
For i = 2 To n Step 2
  Set sum = sum + i
End For
Display "Sum: ", sum
Q2
Declare Integer n
Declare Integer i
Declare Integer sum
Set sum = 0
Set i = 2
For i = 1 To 100
  Display "Enter ", i, ": "
  Input n
  Set sum = sum + n
End For
Display "Sum: ", sum
Q3.Â
Declare Integer n1
Declare Integer n2
Display "Enter number 1: "
Input n1
Display "Enter number 2: "
Input n2
if n1>n2Â
  Display "The largest: ", n1
else
  Display "The largest: ", n2
Q4.Â
Declare Integer n1
Declare Integer n2
Display "Enter number 1: "
Input n1
Display "Enter number 2: "
Input n2
if n1<n2Â
  Display "The smallest: ", n1
else
  Display "The smallest: ", n2
Q5.Â
Declare Integer n1
Declare Integer n2
Declare Integer n3
Declare Integer largest=-111111
Display "Enter number 1: "
Input n1
if n1> largest
  largest=n1
end if
Display "Enter number 2: "
Input n2
if n2> largest
  largest=n2
end if Â
Display "Enter number 3: "
Input n3
if n3> largest
  largest=n3
end if Â
Display "The largest: ", largest
Q6.Â
Declare Integer n
Declare Integer i
Declare Integer largest=-111111
For i = 1 To 100
  Display "Enter ", i, ": "
  Input n
  if n> largest
    largest=n
  end if
End For
Display "The largest number is: ", largest
Comments
Leave a comment