The document outlines a series of programming exercises involving variable declarations, loops, and input/output operations. Each exercise focuses on different tasks such as finding the lowest/highest values, calculating totals and averages, and validating string inputs. The exercises demonstrate basic programming concepts and logic in a structured format.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
13 views5 pages
Cs Homework
The document outlines a series of programming exercises involving variable declarations, loops, and input/output operations. Each exercise focuses on different tasks such as finding the lowest/highest values, calculating totals and averages, and validating string inputs. The exercises demonstrate basic programming concepts and logic in a structured format.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5
CS HOMEWORK
1) DECLARE Count: INTEGER
DECLARE Age: INTEGER DECLARE Lowest: INTEGER Lowest 100 FOR COUNT 1 to 5 Age INPUT “Enter the age” IF lowest>Age Then Lowest Age ENDIF NEXT Count OUTPUT Lowest
2) DECLARE Count: INTEGER
DECLARE Total: REAL DECLARE Marks: REAL Total 0 WHILE Count < 7 DO Marks INPUT “Enter the student marks” Total Total + Marks ENDWHILE OUTPUT Total OUTPUT (Total/7)
3) DECLARE I: INTEGER FOR I 1 TO 5 Name Input “Enter the student name” Next I OUTPUT Name
4) DECLARE Count: INTEGER
DECLARE Lowest: INTEGER DECLARE Highest: INTEGER DECLARE Rent: INTEGER DECLARE Total: INTEGER Lowest 99999999999999 Total 0 Highest 0 FOR Count 1 to 8 Rent INPUT “Enter the rent value” IF Rent > Highest Then Highest Rent ENDIF IF Lowest > Rent Then Lowest Rent ENDIF Total Total + Rent NEXT COUNT OUTPUT Lowest OUTPUT Highest OUTPUT (Total/8)
5) DECLARE Count: INTEGER
DECLARE Height: REAL DECLARE Marks: INTEGER DECLARE Highest: REAL DECLARE Lowest: REAL DECLARE TotalM: REAL DECLARE TotalH: REAL Highest 0 Lowest 1000 TotalM 0 TotalH 0 INPUT Students FOR Count 1 to Students INPUT Marks TotalM TotalM + Marks INPUT Height TotalH TotalH + Height IF Height > Highest Then Highest Height ENDIF IF Lowest > Height Then Lowest Height ENDIF NEXT Count OUTPUT TotalM OUTPUT TotalH OUTPUT Highest OUTPUT Lowest OUTPUT (TotalH/Students)
6) DECLARE Count: INTEGER
DECLARE Total: REAL DECLARE Price: REAL DECLARE CountN: INTEGER Total 0 CountN 0 WHILE Count < 6 DO Price INPUT “Enter the price of the item” Total Total + Price IF Price > 100 Then CountN CountN + 1 ENDIF ENDWHILE OUTPUT Total OUTPUT CountN OUTPUT ((CountN/6)*100)
7) DECLARE Count: INTEGER
DECLARE Total: REAL DECLARE Price: REAL Count 1 Total 0 REPEAT Price INPUT “Enter the price of the item” Total Total + Price Count Count + 1 UNTIL Count = 6 OUTPUT Total
8) PROCEDURE Validate (ThisString)
DECLARE I: INTEGER DECLARE Char: STRING DECLARE UPCase: INTEGER DECLARE LCase: INTEGER FOR I 1 TO LENGTH (ThisString) Char MID (ThisString, Count, 1) IF Char >= 0 and Char <= 9 Then Digits Digits + 1 ENDIF IF Char >= “A” and Char <= “Z” Then UPCase UPCase + 1 ENDIF IF Char >= “a” and Char <= “z” Then LCase Lcase + 1 ENDIF NEXT I OUTPUT Digits OUTPUT UPCase OUTPUT LCase END PROCEDURE CALL Validate(ThisString)