0% found this document useful (0 votes)
22 views5 pages

Task-26 06 2024

task to learn c well

Uploaded by

thanikad.ei24
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)
22 views5 pages

Task-26 06 2024

task to learn c well

Uploaded by

thanikad.ei24
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/ 5

Total Marks - 30

Task 1:
Craft a program that prompts the user to enter the principal amount and
time period in years as input. Then the program calculates the simple
interest based on the principal amount (P) and the time period in years (T).
The program should use the following interest rate conditions:
● If the principal amount (P) is between 1000 and 5000 (inclusive), the
rate of interest (R) is 5%.
● If the principal amount (P) is between 5001 and 10000 (inclusive),
the rate of interest (R) is 7%.
● If the principal amount (P) is above 10000, the rate of interest (R) is
10%.
Calculate and display the simple interest.

Sample Input:
principal amount: 6000
time period in years: 3
Sample Output:
The simple interest is: 1260.00

Test Cases
1) 4500
2

2) 8000
4

3) 15000
5

Task 2:
Create a program that reads an integer input representing a month (1-12)
and outputs the corresponding season using nested if-else statements. The
seasons should be categorised as follows:
● Winter: December (12), January (1), February (2)
● Spring: March (3), April (4), May (5)
● Summer: June (6), July (7), August (8)
● Autumn: September (9), October (10), November (11)
● Finally, check if the month is not within the range, then print as
“Invalid month number”.

SAMPLE INPUT:
4
SAMPLE OUTPUT:
Spring

TEST CASES:
1) 1
2) 7
3) 11
4) 13

TASK 3:
Craft a program to prompt the user to enter the cost price (CP) and selling
price (SP) of an item.
1. Calculate the profit or loss based on the given formulas:
○ If SP > CP, then profit = SP - CP.
○ If CP > SP, then loss = CP - SP.
○ If SP = CP, then no profit, no loss.
2. Display the type of transaction:
○ "Profit of Rs. <profit>" if there is a profit.
○ "Loss of Rs. <loss>" if there is a loss.
○ "No profit, no loss" if SP equals CP.

Sample Input
Enter the cost price (CP): 1500
Enter the selling price (SP): 2000
Sample Output
Profit of Rs. 500

Test Cases
1) 1000
1500

2) 2000
1500

3) 1200
1200

Sample:

Task 1:

Code:

Output Screenshot

Task 4:
Craft a program first takes an input year from the user.Determine if the
input year is a leap year and calculates the next leap year accordingly:
● If the year is divisible by 4 but not by 100, it increments the year by 4
to find the next leap year.
● If the year is divisible by 100 but not by 400, it adjusts the year
similarly.
● If the year is divisible by 400, it directly adds 4 to find the next leap
year.
● Finally, it prints the next leap year after the input year.

Sample Input:
2023
Sample Output:
2024

Test Cases:
1) 2010
2) 2002
3) 1990

Task 5 :
Craft a program that prompts the user to enter two numbers and choice as
input, then displays a menu with the following choices:
1. Compute the sum of the two numbers.
2. Compute the difference (first number - second number).
3. Compute the product of the two numbers.
4. Compute the quotient (first number / second number), ensuring to
handle division by zero.
5. Compute the remainder (first number % second number), ensuring to
handle division by zero.

Sample Input
Enter the first number: 10
Enter the second number: 5
Enter your choice: 1
Sample Output
The sum of 10 and 5 is 15

Test Cases
1) 84
93
4
2) 78
12
2
3) 14
59
3
4) 12
78
5

You might also like