0% found this document useful (0 votes)
19 views3 pages

Pps I Assignment I Jyothi

Uploaded by

akshithabhi2812
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
19 views3 pages

Pps I Assignment I Jyothi

Uploaded by

akshithabhi2812
Copyright
© © All Rights Reserved
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/ 3

Programming for Problem Solving-I

Assignment-I

1. Mr. Benjamin was suffering from a high fever so he went to a hospital to consult a doctor.
The doctor measured his temperature in Fahrenheit. Now help Benjamin to know his
temperature in centigrade. Write a C Program to it.
HINT: 00 C= (F-32)*5/9 Input Output 1020F 38.88890 C

2. Kashyap is very strong in programming as a part of this his teacher has given him a task. Now
it’s your aim to help Kashyap complete his task Given a number N, the task is to find whether the
number is a prime number (or) not. Input N=7 Output Prime number Input N= 9 Output is Not a
prime

3. Prof Martin has taught students the concepts related to Iterative models, with respect to this he
asked his students to complete a task. Given a number N, the task is to find 1+2+3+…… ..+N
Input N= 5 Output 15 Input N =3 Output 6

4. Ritish a store manager at phoenix mall. He was asked to create a price tag for different
perfumes of different brands by seeing a unique Id value. Now write a program which satisfies
the price tags. Input Format: Read ‘N’, as an integer value Input: 5 Output: price tag=120
(1*2*3*4*5) Input: 4 Output: price tag= 24

5. A Calculator is a small electronic device used to perform various arithmetic operations like
addition, subtraction, multiplication, division, percentage, etc. It makes our calculations easier
and faster. It is a portable device that can use anywhere to perform simple mathematical
operations. Dear students write a program to create a Calculator program using switch statement
Read an input in character mode (+,-,*,/,%) If ‘+’ is chosen we need to read two input numbers
from the user and print their sum, likely if ‘*’ is chosen print their product and so on …………..
Expected Input and Output

Test _case:1 Select an operator (+, -, *, /, %)

Input: * 50 8 Output Result= 400

Explanation: 50*8=400 Test _case:2

Select an operator (+, -, *, /, %) Input: - 78 -90

Output Result = -12 Explanation: 78 – 90 = -12


6. A cargo shipment containing three items with different weights has just arrived at a port,
which requires some regrouping in such a way that you need to pick the maximum
weight of the three items.
Now your task is to implement a program which satisfies the above requirements.
Input Format: Read input as three integer’s w1, w2, w3.
Input: w1=700, w2=1000, w3=500 Output: 1000 is maximum.
Input: w1=800, w2=1000, w3=5000 Output: 5000 is maximum.

7. Mr. Kane William’s basic salary is given as input through the keyboard. His dearness
allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write
a program to calculate his gross salary. (Hint: gross salary = basic salary + dearness
allowance + house rent allowance)

8. A library charges a fine for every book returned late. For first 5 days the fine is 1 rupee,
for 6-10 days fine is two rupees and above 10 days fine is 5 rupees. If you return the book
after 30 days your membership will be cancelled. Write a program to accept the number
of days the member is late to return the book and display the fine or the appropriate
message.

9. Using the Switch statement, write a program that displays the following menu for the
food items available to take orders from the customer:
• B= Burger
• F= French Fries
• P= Pizza
• S= Sandwiches
The program inputs the type of food and quantity. It finally displays the total charges for
the order according to the following criteria:
Consider the cost of a burger as Rs 200, the cost of French fries as Rs 50, the cost of a
pizza as Rs 500, and the cost of a sandwich as Rs 150.
Expected Input and Output
Test _case:1
b=Burger

f=French Fries
p=pizza
s=Sandwiches
Enter your order using the first letters as (b,f,s,p)
f
your order is french_fries
please enter your quantity 10
Output:
your total charges is: 500
Explanation: Total charge= quantity*actual price
The actual price of French fries is Rs 50 => 10*50 =500
Test _case:2
b=Burger
f=French Fries
p=pizza
s=Sandwiches
Enter your order using the first letters as (b,f,s,p)
Y
Output:
Please your request is not available, visit another restaurant
Explanation: y is not taken as a label name.

10. a) Write a C Program to check whether a given number is Palindrome or not.


b) Write a C Program to check whether a given number is Prime or not.

You might also like