0% found this document useful (0 votes)
2 views6 pages

Conditional Structures in Pseudocode

The document contains pseudocode for various programming assignments related to conditional structures. It includes algorithms for checking odd/even numbers, finding the largest among three numbers, checking leap years, and determining character types, among others. Each section outlines the steps for implementing the logic in a structured format.

Uploaded by

sabib75580
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)
2 views6 pages

Conditional Structures in Pseudocode

The document contains pseudocode for various programming assignments related to conditional structures. It includes algorithms for checking odd/even numbers, finding the largest among three numbers, checking leap years, and determining character types, among others. Each section outlines the steps for implementing the logic in a structured format.

Uploaded by

sabib75580
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

Name: Niyitanga Denys

ID: 29125

Course: Introduction to Computer Programming

Date: October 08, 2025

CONDITIONAL STRUCTURE ASSIGNMENT (PSEUDOCODE)

A. Check Odd or Even


START
DECLARE num AS INTEGER
OUTPUT "Enter an integer: "
INPUT num
IF num M% 2 == 0 THEN
OUTPUT "Number is even"
ELSE
OUTPUT "Number is odd"
ENDIF
END

B. Largest Among Three Numbers


START
DECLARE a, b, c AS INTEGER
OUTPUT "Enter three numbers: "
INPUT a, b, c
IF a > b AND a >c THEN
OUTPUT a, "is the largest"
ELSE IF b > a AND b > c THEN
OUTPUT b, "is the largest"
ELSE
OUTPUT c, "is the largest"
ENDIF
END

C. Largest Number Using Conditional Operator


START
DECLARE a, b largest AS INTEGER
OUTPUT "Enter three numbers: "
INPUT a, b, c
largest (a > b)? “ a is the largest number”:” b is the largest number”
END

D. Check Leap Year Using Conditional Operator


START
DECLARE year AS INTEGER
OUTPUT "Enter a year: "
INPUT year
(year MOD 4 = 0 AND year MOD 100 <> 0) OR (year MOD 400 = 0) ?
OUTPUT "Leap year” : OUTPUT "Not a leap year"
END

E. Check Alphabet
START
DECLARE ch AS CHARACTER
OUTPUT "Enter a character: "
INPUT ch
IF (ch >= 'A' AND ch <= 'Z') OR (ch >= 'a' AND ch <= 'z') THEN
OUTPUT "Alphabet"
ELSE
OUTPUT "Not an alphabet"
ENDIF
END

F. Check Positive, Negative, or Zero


START
DECLARE num AS INTEGER
OUTPUT "Enter a number: "
INPUT num
IF num > 0 THEN
OUTPUT "Positive"
ELSE IF num < 0 THEN
OUTPUT "Negative"
ELSE
OUTPUT "Zero"
ENDIF
END

G. Check Uppercase or Lowercase


START
DECLARE ch AS CHARACTER
OUTPUT "Enter a character: "
INPUT ch
IF ch >= 'A' AND ch <= 'Z' THEN
OUTPUT "Uppercase alphabet"
ELSE IF ch >= 'a' AND ch <= 'z' THEN
OUTPUT "Lowercase alphabet"
ELSE
OUTPUT "Not an alphabet"
ENDIF
END

H. Check Vowel or Consonant


START
DECLARE ch AS CHARACTER
OUTPUT "Enter a character: "
INPUT ch
IF ch IN ['A','E','I','O','U','a','e','i','o','u'] THEN
OUTPUT "Vowel"
ELSE
OUTPUT "Not a vowel"
ENDIF
END

I. Check Alphabet, Digit, or Special Character


START
DECLARE ch AS CHARACTER
OUTPUT "Enter a character: "
INPUT ch
IF (ch >= 'A' AND ch <= 'Z') OR (ch >= 'a' AND ch <= 'z') THEN
OUTPUT "Alphabet"
ELSE IF ch >= '0' AND ch <= '9' THEN
OUTPUT "Digit"
ELSE
OUTPUT "Special character"
ENDIF
END

J. Print Day Name of the Week


START
DECLARE day AS INTEGER
OUTPUT "Enter day number (1-7): "
INPUT day
SWITCH day number
CASE 1: OUTPUT "Sunday"
CASE 2: OUTPUT "Monday"
CASE 3: OUTPUT "Tuesday"
CASE 4: OUTPUT "Wednesday"
CASE 5: OUTPUT "Thursday"
CASE 6: OUTPUT "Friday"
CASE 7: OUTPUT "Saturday"
DEFAUL:OUTPUT "Invalid input"
ENDSWITCH
END

K. Check Equality of Two Integers


START
DECLARE a, b AS INTEGER
OUTPUT "Enter number: "
INPUT a
OUTPUT “enter another number”
INPUT b
IF a = b THEN
OUTPUT "Numbers are equal"
ELSE
OUTPUT "Numbers are not equal"
ENDIF
END

L. Check Voting Eligibility


START
DECLARE age AS INTEGER
OUTPUT "Enter your age: "
INPUT age
IF age >= 18 THEN
OUTPUT "Eligible to vote"
ELSE
OUTPUT "Not eligible to vote"
ENDIF
END

M. Eligibility for Engineering Admission


START
DECLARE math, physics, chemistry AS INTEGER
OUTPUT "Enter marks in Math, Physics, and computer: "
INPUT math, physics, computer
total math + physics + computer
IF math >= 60 AND physics >= 60 AND computer >= 50 THEN
OUTPUT "Eligible for admission"
ELSE
OUTPUT "Not eligible"
ENDIF
END
N. Calculate Total Marks, Percentage, and Division
START
DECLARE s1, s2, s3, s4, s5, total AS INTEGER
DECLARE percentage AS REAL
OUTPUT "Enter marks for 5 subjects: "
INPUT s1, s2, s3, s4, s5
total = s1 + s2 + s3 + s4 + s5
percentage = total / 5
IF percentage >= 84 THEN
OUTPUT "First Division"
ELSE IF percentage >= 60 THEN
OUTPUT "Second Division"
ELSE IF percentage >= 45 THEN
OUTPUT "Third Division"
ELSE
OUTPUT "Fail"
ENDIF
END

O. Days in a Month
START
DECLARE month AS INTEGER
OUTPUT "Enter month number (1-12): "
INPUT month
SWITCH month number
1,3,5,7,8,10,12: OUTPUT "31 days"
4,6,9,11: OUTPUT "30 days"
2: OUTPUT "28 or 29 days"
OTHERWISE OUTPUT "Invalid month"
ENDSWITCH
END

P. Check Triangle Formation by Angles


START
DECLARE angle1, angle2, angle3, sum AS INTEGER
OUTPUT "Enter three angles: "
INPUT angle1, angle2, angle3
sum angle1 + angle2 + angle3
IF sum = 180 THEN
OUTPUT "Triangle can be formed"
ELSE
OUTPUT "Triangle cannot be formed"
ENDIF
END

You might also like