0% found this document useful (0 votes)
19 views

AFB Assignment-1

Uploaded by

Aaditya Byadwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

AFB Assignment-1

Uploaded by

Aaditya Byadwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

AFB

Assignment-1

Instruction:
• Please go through the PPTs before solving the questions. Some concepts
may not have been discussed in class due to limited time.

1. Write a program to read the marks of 5 subjects through the keyboard. Find out the
aggregate and percentage obtained by the student. Assume maximum marks that can
be obtained by a student in each subject as 100.
2. Write a program to read a four-digit number through the keyboard and calculate the
sum of its digits.
3. Write a program to read the distance between any two cities in kilometer(km) and
print the distances in meters(m), centimeter(cm) and miles.
Note: 1 km = 1000 meter
1 km = 100000 centimeter
1 km = 0.6213 miles
4. Write a program to read the weight of an object in kilogram and print its weight in
pound and ton.
Note: 1 kg = 2.20 pound
1 kg = 0.001 tonne
5. Read a distance in meters and a time in seconds through the keyboard. Write a
program to calculate the speed of a car in meter/second.
Note: Speed = Distance/Time
6. Write a program to read the radius of a sphere from the user and calculate the volume
of the sphere.
Note: Volume of sphere = 4/3*3.14*r3
7. An ATM contains Indian currency notes of 100, 500 and 1000. To withdraw cash
from this ATM, the user has to enter the number of notes he/she wants of each
currency, i.e., of 100, 500, and 1000. Write a program to calculate the total amount
withdrawn by the person from the ATM in rupees.
8. Write a program to prompt (input) year and check if it is a leap year.
9. Write a program to calculate an Internet browsing bill. Use the conditions specified as
follows:
a. 1 Hour - ₹20
b. ½ Hour - ₹10
c. Unlimited hours in a day - ₹100
The owner should enter the number of hours spent on browsing.
10. Write a nested if statements to print the appropriate message depending on the value
of the variables temperature and humidity as given as follows. Assume that the
temperature can only be warm and cold and the humidity can only be dry and humid.
if temperature is If humidity is Print the activity
Warm Dry Play Basketball
Warm Humid Play Tennis
Cold Dry Play Cricket
Cold Humid Swim

11. Write a program to calculate the square of only those numbers whose least significant
digit is 5.
Example: Enter the number: 25
Square: 25*25 = 625
12. Write a program that asks for input n and prints sequence of powers of 5 from 50 to 5n
in separate lines.
Note: The input number n should be positive.
Example:
Input: N=4
Output:
1
5
25
125
625

13. Write a program to display the numbers of a series 1, 4, 9, 16, 25, …, n by using for
loop.
14. Write a program using the while loop, which prints the sum of every fifth number
from 0 to 500 (including both 0 and 500).
15. Write a program using the while loop to read the positive integer and count the
number of decimal digits in a positive integer.
16. Write programs for the following series using the while loop.
a. x+x2/!2+ x3/!3+…n
b. 1+x+x2+x3+…xn

You might also like