0% found this document useful (0 votes)
14 views2 pages

Programming Challenges: Variables & Logic

The document outlines three programming tasks: A) Create a program to sum five integers using only two variables and a while loop; B) Determine a personal title based on age and gender; C) Evaluate a mathematical expression using ASCII values derived from the string 'PUCIT'. Each task includes input requirements and sample test cases to illustrate expected outputs. The tasks focus on basic programming concepts such as loops, conditionals, and arithmetic operations.

Uploaded by

riziwattoo804
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)
14 views2 pages

Programming Challenges: Variables & Logic

The document outlines three programming tasks: A) Create a program to sum five integers using only two variables and a while loop; B) Determine a personal title based on age and gender; C) Evaluate a mathematical expression using ASCII values derived from the string 'PUCIT'. Each task includes input requirements and sample test cases to illustrate expected outputs. The tasks focus on basic programming concepts such as loops, conditionals, and arithmetic operations.

Uploaded by

riziwattoo804
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

A) Variables Shortage!

Write a program that takes 5 integers from the user and displays their sum on screen. But you can
only use two variables. (Use While Loop)
Input:-
The first line contains 5 Numbers.
Output:-
Display The Sum of All Five Numbers.
Sample Test Cases:-
1. 1 2 3 4 5
2. -12 -4 5 7 1
Sample Output:-
1. 15
2. -3

B) Who I’m?
Depending on age (decimal number and gender (m / f), print a personal title:
● “Mr.” – a man (gender “m”) – 16 or more years old.
● “Master” – a boy (gender “m”) under 16 years.
● “Ms.” – a woman (gender “f”) – 16 or more years old.
● “Miss” – a girl (gender “f”) under 16 years.
Test Cases:-
1)
Enter your age: 18
Enter your Gender (m/f): m
Your personal title is : Mr
2)
Enter your age: 12
Enter your Gender (m/f): f
Your personal title is : Miss

C) Can You Guess The Password?


PUCIT's Programming Fundamentals Lab has locked the final exam password inside a
mathematical expression. He claims that only students who truly understand characters and
numbers can unlock it!
Your task is to evaluate the following secret expression:
Result=(B−A)×(C/D)+(F-E)
But wait! The values aren’t directly given! Instead, you must extract them from characters as
follows:
 A → ASCII value of the first letter in “PUCIT”
 B → ASCII value of the last letter in “PUCIT”
 C → ASCII value of ‘P’ plus ASCII value of 'U'
 D → Total letters in “PUCIT”
 E → ASCII value of 'C'
 F → ASCII value of 'T'
Input Format:
No input required! Your program should directly compute the values.
Output Format:
Print the computed Result based on the formula.

You might also like