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

Challenge Day 5

The document contains 14 coding exercises with varying levels of complexity. The exercises cover topics like variables, arrays, conditionals, loops, and mathematical operations. They provide examples of coding fundamentals and how to structure simple programs to solve different problems.

Uploaded by

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

Challenge Day 5

The document contains 14 coding exercises with varying levels of complexity. The exercises cover topics like variables, arrays, conditionals, loops, and mathematical operations. They provide examples of coding fundamentals and how to structure simple programs to solve different problems.

Uploaded by

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

Exercise1

START
Create a variable sum
Enter The first number
Store the first number in a variable num1
Enter The second number
Store the second number in a variable num2
Set sum = num1 + num2
Display sum
END

Exercise2
START
Create a variable Average
Create a variable Sum
Enter the first number
Store the first number in a variable num1
Enter the second number
Store the first number in a variable num2
Enter the third number
Store the third number in a variable num3
Set Sum = num1 + num2 + num3
Set Average = Sum / 3
display Average
END

Exercise3
START
Enter a number
create a variable result = number / 2
IF result is integer THEN
display number is even
IF result is float THEN
display number is odd
END

Exercise4
START
Enter a first number
Store number in variable A
Enter a second number
Store number in variable B
Enter a second number
Store number in variable C
If A is greater than B AND B greater than C THEN
display A
If B is greater than A AND A greater than C THEN
display B
IF NOT THEN
display C
END

Exercise5
START
Enter A number
Store the number in a variable num
IF num = 0
display 1
Create a variable Fact = 1
Iterate from i = 2 to i = num THEN
Fact = Fact * i
i = i + 1
End Iteration
display factorial of the num is Fact
END

Exercise6
START
Enter your age
if age is greater than or equal 18 THEN
display you are eligible to vote
if not THEN
display you are not eligible to vote
END

Exercise7:
START
Enter a sentence
Create a variable counter
Set counter = 0
Iterate through the sentence THEN
IF you find the character " " THEN
counter = counter + 1
endIF
END iteration
display the number of words is counter
END

Exercise8
START
Enter the numbers
Put the numbers into a array
Create a variable sum
Set sum = 0
iterate i = 0 to i = the array length - 1 THEN
IF array[i] > 0 THEN
sum = sum + array[i]
endIF
end Iteration
display sum
END

Exercise9:
START
Create an array A
Iterate k = 1 to k = 7
display Enter a number
put number in A
End Iteration
Create a variable min
min = A[0]
Iterate i = 1 to i = 6
if A[i] < min THEN
min = A[i]
end if
end iteration
display the smallest value is min
display the position i
END

Exercise10:
Start
Create an array H
Create a variable counter = 0
display enter your N
iterate k = 0 to k = 9
enter the number
put number in H
end iteration
iterate i = 0 to k = 9
IF H[i] = N THEN
counter = counter + 1
end iteration
display the number of occurrences is counter
END

Exercise11:
Start
Create an array T
create an array T1
create an array T2
iterate k = 1 to k = 10
enter a number
put number in T
Iterate from i = 0 to i = 9
result = T[i]/2
IF result is an integer
T1 = T[i]
IF not
T2 = T[i]
End iteration
display T1
display T2
END

EXERCISE12:
START
i = 0
repeat
display i = i * 8
i = i + 1
until i < 10
END

Exercise13
Start
Enter a price
ratioReduction = reduction/100
VAT = 20/100
amountToReduce = price * ratioReduction
priceAfterReduction = price - amountToReduce
taxAmount = price * VAT
totalPrice = price + taxAmount
END

Exercise14
START
Enter number n
Enter number m
IF (m = 0 and n = 0)
display product is zero
IF (m=0 or n!=0) or (m!=0 or n=0)
display product is zero
IF (m>0 and n>0) or (m<0 and n<0)
display product is positive
IF (m<0 and n>0) or (m>0 and n<0)
display product is positive
END

You might also like