Logical Assignment: Code Segment Analysis for Senior Citizen Discount - Prof. Marjory Baru, Assignments of Computer Science

An analysis of a logical code segment in c programming language, which determines if a person is a senior citizen based on their age and applies a 10% discount accordingly. Understand the logic behind the code segment and its output for different age inputs.

Typology: Assignments

Pre 2010

Uploaded on 08/09/2009

koofers-user-7o6
koofers-user-7o6 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
LOGICAL ASSIGNMENT
Nonzero interpreted as True
Zero interpreted as False
int seniorCitizen, age;
...
seniorCitizen = (age > 65);
trace this code segment
age seniorCitizen
50 0 (false)
70 1 (true)
if (seniorCitizen)
price = .9 * price; /* 10% discount */

Partial preview of the text

Download Logical Assignment: Code Segment Analysis for Senior Citizen Discount - Prof. Marjory Baru and more Assignments Computer Science in PDF only on Docsity!

LOGICAL ASSIGNMENT

Nonzero interpreted as True Zero interpreted as False int seniorCitizen, age; ... seniorCitizen = (age > 65); trace this code segment age seniorCitizen 50 0 (false) 70 1 (true) if (seniorCitizen) price = .9 * price; /* 10% discount */