Assignment 1
Assignment 1
Task 1
Draw the flowchart of a program that prints the first ten positive whole numbers. [Do NOT use loops]
Task 2
Draw the flowchart of a program that prints the first ten even positive whole numbers. (Do NOT use loop or
modulus operator for this problem).
Task 3
Draw the flowchart of a program that reads one number from the user, and prints it back to show which
number was entered by the user.
Task 4
Draw the flowchart of a program that reads two numbers from the user, and prints their sum, product and
difference.
Task 5
Draw the flowchart of a program that reads the radius of a circle and prints its circumference and area.
Task 6
Draw the flowchart of a program that reads two numbers from the user and prints “first” if the first number
is greater than the second number.
Task 7
Draw the flowchart of a program that reads two numbers from the user. Your program should then print
“first is greater” if the first number is greater, and “first is not greater” otherwise.
Task 8
Draw the flowchart of a program that reads two numbers from the user. Your program should then print
“first is greater” if the first number is greater, “second is greater” if the second number is greater, and “the
numbers are equal” otherwise.
Task 9
Draw the flowchart of a program that reads two numbers, subtracts the smaller number from the larger
one, and prints the result.
Task 10
Draw the flowchart of a program that reads a number, and prints “The number is even” or “The number is
odd”, depending on whether the number is even or odd. (Hint: use the modulus operator)
Task 11
Draw the flowchart of a program that reads five numbers from the user, and prints their average. [Do NOT
use loops]
Task 12
Draw the flowchart of a program that finds the sum of the first 100 positive numbers. Verify your answer by
calculating this sum manually. [Do NOT use loops, use the mathematical formula]
Task 13
Draw the flowchart of a program that reads five numbers as input from the user, and prints whether the
numbers are odd or even. [Do NOT use loops]
Task 14:
Draw the flowchart of a program that reads an integer, and if the number is even and greater than 10,
prints “An even number greater than 10”. If the number is even but lesser than 10, print “An even
number not greater than 10”. If the number is greater than 10 but odd, print “An odd number greater
than 10”. If the number is odd and also less than 10, print “An odd number less than 10”.
Task 15:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of either
2 or 5.
For example, 2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22 …
Task 16:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of either
2 or 5 but not both.
For example, 2, 4, 5, 6, 8, 12, 14, 15, 16, 18, 22 …
Task 17:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of 2 and
5.
For example, 10, 20, 30, 40, 50 …
Task 18:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of
NEITHER 2 NOR 5.
For example, 1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39 …
Task 19:
Draw the flowchart of a program that reads an integer, and prints the integer if it is NOT a multiple of 2
OR NOT a multiple of 5.
Task 20:
Draw the flowchart of a program that reads a student’s mark for a single subject, and prints out “Pass”
if the student got more than 50, and “You shall not pass” otherwise.
Task 21:
Draw the flowchart of a program that reads a student’s mark for a single subject, and prints out the
corresponding grade for that mark. The mark ranges and corresponding grades are shown in the table
below.
Marks Grade
90 and above A
80-89 B
70-79 C
60-69 D
50-59 E
Below 50 F
22. Draw the flowchart that takes as input your final marks and shows as output the letter grade.
90 - 100 = A (4.0) Excellent
85 - <90 = A- (3.7)
80 - <85 = B+ (3.3)
75 - <80 = B (3.0) Good
70 - <75 = B- (2.7)
65 - <70 = C+ (2.3)
60 - <65 = C (2.0) Fair
57 - <60 = C- (1.7)
55 - <57 = D+ (1.3)
52 - <55 = D (1.0) Poor
50 - <52 = D- (0.7)
<50 = F (0.0) Failure
23. Write a flowchart for finding area of a rectangle given height and width.
24. Write a flowchart for a program that performs four functions of a calculator. The program should
request the user to enter a floating-point number, an operator and another floating-point number. It should
then carry out the specified arithmetical operation: adding, subtracting, multiplying, or dividing the two
floating-point numbers. Finally, it should display the result.
27. Write a flowchart that finds the number of hours, minutes, and seconds in a given number of seconds.
For example, how many hours, minutes, and seconds are there in 10,000 seconds?
28. Suppose the following expressions are used to calculate the values of L for different values of S:
Write a flowchart of a program that reads a value of S and then calculates the value of L.
29. Write a flowchart that reads the values for the three sides x, y, and z of a triangle, and then calculates
its area. The area is calculated as follows: area s ( s x )( s y )( s z )
x yz
where s is
2
30. A leading newspaper pays all their freelance writers at a rate of Tk. 500 per published article. Draw the
flowchart for a program that will read the number of published articles for one writer, and print the total
monthly fees for that writer.
31. Given number of courses, credits in each course and per credit cost, find how much a student have to
pay for a particular semester.
32. Suppose the following expressions are used to calculate the values of P for different values of Q:
P = 6000 15Q 2 if Q 50
1000
if Q 50
3 Q 2 1900
P=
Write a flowchart that reads a value of Q and then calculates the value of P.
Example: If the user enters “Toyota” and 20, your program should print the name Toyota 4 times.
34. Imagine following call rates for a cell phone operator. Write a flowchart that calculates call charge given
the type of number, start and end time (hour and minute only).
F&F Other Numbers
Hour
1st 5 minute Rest 1st 5 minute Rest
Peak 4tk/min 2tk/min 7tk/min 6tk/min
Off Peak 3tk/min 1tk/min 8tk/min 5tk/min
35) Take hour from the user as input and tell it is time for which meal.
User will input the number in 24-hour format say 14 to mean 2pm, 3 to
mean 3am, 18 to mean 6pm etc.
Valid inputs are 0 to 23. Inputs less than 0 or more than 23 are
invalid in 24-hour clock.
Input will be whole numbers. For example, 3.5 will NOT be given as input.
For example,
If the user enters 4, your program should print the message "Breakfast".
If the user enters 5, your program should print the message "Breakfast".
If the user enters 6, your program should print the message "Breakfast".
If the user enters 0, your program should print the message "Patience
is a virtue".
If the user enters 1, your program should print the message "Patience
is a virtue".
If the user enters 18, your program should print the message "Patience
is a virtue".
If the user enters 23, your program should print the message "Patience
is a virtue".
If the user enters 24, your program should print the message "Wrong Time".
If the user enters -1, your program should print the message "Wrong Time".
If the user enters 27, your program should print the message "Wrong time".
36) Assume all first semester students have 4 courses: CSE110, ENG091, MAT110, PHY111.
Credits for these courses are 3, 0, 3, and 3 respectively.
Take the grades of four courses from the user (out of 4.0 scale) and then print the GPA
Formula:
GPA
= summation of (multiplication of grade and credit of each course) divided by sum of credits
= (grade1xcredit1 + grade2xcredit2 + grade3xcredit3 ....) / (credit1 + credit 2+credit 3 ....)