You are on page 1of 7

Q1.

Write a pseudo code that prints ‘Hi’ 50 times using

 While loop

Count = 1

WHILE Count <= 50

OUTPUT “Hi”

COUNT ← COUNT + 1

ENDWHILE

 For loop
a=0
For a ← 1 TO 50
OUTPUT “Hi”
ENFOR

Q2. Print counting 1 to 100 using for loop and while loop

DECLARE a : INTEGER

WHILE a <= 100

OUTPUT a

a←a+1

ENDWHILE

Q3. Output counting from 20-48 inclusive.

NUMBER = 1

WHILE NUMBER >= 20 AND <= 48

OUTPUTT NUMBER

ENDWHILE
NUMBER = NUMBER + 1

Q4.Print all evn nos between 100 to 150

DECLARE NUMBER : INTEGER

NUMBER = 100

FOR COUNT = 100 TO 150

IF NUMBER / 2 = 0

THEN
OUTPUT NUMBER

ENDIF

ENDFOR

Q5.Print all odd numbers between 100 to 150

COUNT = 100

FOR COUNT 100 TO 150

IF COUNT % 2 = 1

OUTPUT COUNT

Q6.Print sum of 50 numbers ( take input from user)


DECLARE SUM, NUMBERS, COUNT, : INTEGER

SUM = 0

FOR COUNT =1 TO 50

OUTPUT = (“ENTER YOUR DESIRED NUMBERS”)

NUMBERS = INPUT

SUM = SUM + NUMBERS

ENDFOR

OUTPUT SUM

Q7ask the user to input 20 numbers and count how many are positive, negative or zero

DECLARE ZERO, POSITIVE, NUMBER,NEGATIVE : INTEGER

ZERO = 0

POSITIVE = 0

NUMBER = 0

NEGATIVE = 0

FOR COUNT 0 TO 20
OUTPUT = (“ENTER YOUR DESIRED NUMBER”)

NUMBER = INPUT

IF NUMBER = 0

THEN

ZERO = ZERO + 1

ELSEIF NUMBER >= 1

THEN

POSITIVE = POSITIVE + 1

ELSE

NEGATIVE = NEGATIVE + 1

ENDOFR

ENDIF

ENDIF

Q8 ask the user to input 20 numbers and output whether each no is odd or even?

DECLARE EVEN, ODD, NUMBER: INTEGER

EVEN =0

ODD = 0

NUMBER = 0

FOR COUNT = 1 TO 20

OUTPUT = (“ ENTER THE SET OF NUMBERS TO BE TESTED FOR ODD AND EVEN”)

NUMBER = INPUT

IF NUMBER % 2 = 0

THEN

EVEN = EVEN + 1

ELSE

ODD = ODD + 1
ENDFOR

ENDIF

OUTPUT ( “ OUT OF THE TWENTY NUMBERS YOU HAVE ENTERED, THE NUMBER OF ODD NUMBERS
ARE”, ODD “ THE NUMBER OF EVEN NUMBERS ARE”, EVEN)

Q9.Ask the user to input 30 numbers and output the sum of all positive numbers?

DECLARE NUMBERS, POSITIVE, SUM : INTEGER

NUMBERS = 0

POSITIVE = 0

SUM = 0

FOR COUNT = 0 TO 30

OUTPUT = (“ ENTER YOUR NUMBER”)

NUMBERS = INPUT

IF NUMBERS >= 0 THEN

POSITIVE = NUMBERS

SUM = SUM + POSITIVE

ELSE

OUTPUT(“ YOU HAVE ENTERED A NEGATIVE NUMBER WHICH IS NOT ACEPTED

ENDFOR

OUTPUT (“ THE SUM OF THE POSITIVE NUMBERS IS”, SUM)

Q10 Take 3 numbers from the user and output their sum and average without using loop?

DECLARE NUM1 , NUM2, NUM3 : INTEGER

DECLARE SUM, AVERAGE ← INTEGER

SUM = 0

AVERAGE = 0

OUTPUT ← (“ENTER YOUR NUMBER”)

INPUT NUM1

OUTPUT ← (“ENTER YOUR NUMBER”)


INPUT NUM2

OUTPUT ← (“ENTER YOUR NUMBER”)

INPUT NUM3

SUM = NUM1 + NUM2 + NUM3

AVERAGE = SUM / 3

Q11 Take 20 numbers from user and output their sum and average ? ( using For next and while loop)

DECLARE SUM, AVERAGE ← INTEGER

DECLARE NUMBERS← INTEGER

Numbers = 0

Sum = 0

Average = 0

FOR COUNT = 1 TO 20

OUTPUT← (“ENTER NUMBERS”)

NUMBERS = INPUT

SUM = SUM + NUMBERS

ENDFOR

AVERAGE = SUM / 20

OUTPUT (“ THE SUM OF NUMBERS IS”, SUM, “The average is” AVERAGE)

Q12. Take 10 numbers numbers from user and output their product?

DECLARE NUMBERS : INTEGER

NUMBERS = 1

FOR COUNT = 1 TO 10

OUTPUT “ENTER YOU R NUMBERS


NUMBERS = INPUT

PRODUCT = PRODUCT* NUMBERS

ENDFOR

OUTPUT (PRODUCT)

Q13 Ask the user to input 20 numbers in an array and output the total of the array?

Q14 Ask the user to input 10 numbers in an array and output the max and minimum number?

Q15 Declare an array of 50 number and initialize it with 0?

Q16 write a program that takes array of 50 elements and initialize first two with 88 and 77, then take
input the rest of the element ?

Q17. An array contains 20 element of strings . replace the name “sam” in the array with your name.?

Q18 an array contains 100 integers, output their

Total

Average

Max

Minimum

Q18 declare a 2D array of 10 rows and 3 columns. Initialize the array to 0.

DECLARE BIGARRAY : ARRAY[ 1 :10, 1: 3] OF INTEGER

DECLARE a, b : INTEGER

FOR a = 1 TO 10

FOR b = 1 TO 3

BIGARRAY[ a, b] = 0

ENDFOR a

ENDFOR b

DECLARE

Q19 declare a 2D array of 20 rows and 3 columns and input numbers from user in the 2D array?

DECLARE BIGARRAY : ARRAY[ 1 :20, 1: 3] OF INTEGER

DECLARE a, b : INTEGER

FOR a = 1 TO 20

FOR b = 1 TO 3
BIGARRAY = [a. b]

BIGARRAY[ a, b] = 0

ENDFOR a

ENDFOR b

FOR a = 1 TO 20

FOR b = 1 TO 3
OUTPUT "Enter value for BIGARRAY[" + i + "," + j + "]: "
BIGARRAY[i,j] = INPUT()

ENDFOR a

ENDFOR b

Q20 A 2D array is already defined and initialize output all the elements of 2D array?

You might also like