Sunteți pe pagina 1din 2

PSG COLLEGE OF TECHNOLOGY

DEPARTMENT OF COMPUTER APPLICATIONS


I SEM BE(EEE,MECH,ECE,CIVIL,MET,AUTO,PROD,BIO-MED,ICE,ROBO)/BTECH(FT,TEXT,BIO)
PROBLEM SOLVING AND C PROGRAMMING
2015-2016(ODD SEMESTER)
PROBLEM SHEET -3

WEEK- 3- (Banching and Looping)

1. A bookstore summarizes its monthly transactions by keeping the following information for each
book in stock:
 Book Identification number
 Inventory balance at the beginning of the month
 Number of copies received during the month
 Number of copies sold during the month
Write a C program that accepts the above data for ‘n’ books and then displays the book
identification number and an updated book inventory balance using the relationships:
New balance = Inventory balance at the beginning of the month + Number of copies received
during the month – Number of copies sold during the month.
2. Write a program that prints the range of values divisible by a given input value. This program
requires three inputs. The user is requested to enter a start and an end value (integer), where
(end > start). The third value which the user enters is the divisor (integer). The program must
print only those values perfectly divisible by the divisor between the start and the end value.
3. Students are allowed to work in our computer centre machines only after entering the correct
secret code. If the code is correct the message “Logged In” is displayed. They are not allowed to
log in to the machine until they enter the correct secret code. Write a program to allow the
student to work only if her/she enters the correct secret code.
4. Write a program that computes and displays the charges for a patient’s hospital visit or stay. First
the program should ask if the patient was admitted as an in-patient or out-patient. If the patient
was an in-patient, then the following data should be entered.
 The number of days spent in the hospital(Rs.1000 per day)
 The daily rate(Rs.50)
 Hospital medication charges(Rs.100 per day)
 Charges for Hospital services( Rs.500) for any number of days
The program should ask for the following data if the patient was an out-patient.
 Charges for hospital services(Rs.650)
 Hospital Medication charges(Rs.200)
Write an interactive program that computes the patient’s bill if any patient wants to leave the
hospital after the visit or stay.

5. Write a program that helps the user to perform basic arithmetic operations such as addition,
subtraction, multiplication, division and modulus. The program should request the user to enter
two integers to be used in the selected mathematical operation. Perform the operation and print
the result. Use switch and case statements to code this program.
Examples
Below are two runs of the program.
A for addition,
S for subtraction,
M for multiplication
D for division
m for Modulus

Enter a valid Choice: M


Enter an integer value: 12
Enter a second integer value: 5
The answer is 60

S-ar putea să vă placă și