03-134232-002 Abdul Moiz Computer Programming Assignment 1
03-134232-002 Abdul Moiz Computer Programming Assignment 1
Instructions:
1) Understanding of each question is a part of the assignment.
2) It is a handwritten assignment. You need to solve it on a paper in your handwriting.
3) Take the snaps/scan of each solved question and paste it in the document under the
question in given space. You can use CAMSCANNER app for taking snaps also or use
your normal mobile camera. Please take clear images
4) Try to think of a solution of your own. If you will keep on searching solutions on Google,
it will not make your problem-solving ability strong. This assignment is to sharp your
mind a bit or making you able to solve/think of a solution for any problem.
5) Copied assignments (from each other) will be awarded with ZERO.
6) Assignment is to be submitted in soft form on LMS as well as in hard form till the
deadline mentioned above.
Enrollment Number: 03-134232-002_
Question 1 Marks: 2.5+2.5 = 05
Write an algorithm and draw a flow chart for the given problem:
Create an algorithm and a flowchart that will compute the area of circle
Hint: A=π r 2
Algorithm:
Flow Chart:
Question 2
Marks: 2.5+2.5 = 05
Write solution and draw a flow chart for the given problem:
Create an algorithm and a flowchart that will compute the sum of two
numbers. If the sum is below or equal to twenty, two numbers will be entered
again. If the sum is above 20, it will display the sum.
Algorithm:
Flow Chart:
Page 2 of 15
Enrollment Number: 03-134232-002_
Page 3 of 15
Enrollment Number: 03-134232-002_
Page 4 of 15
Enrollment Number: 03-134232-002_
Flow Chart:
Page 5 of 15
Enrollment Number: 03-134232-002_
Page 6 of 15
Enrollment Number: 03-134232-002_
Q No 4:
Write a program to check whether a given number is even or odd.
Q No 5:
Write a program to read temperature in centigrade and display a suitable message according
to temperature state below:
Temp<0 then freezing weather
Temp 0-10 then very cold weather
Temp 20-30 then Normal in Temp
Temp 30-40 then it’s Hot
Temp >=40 then it’s very hot
Page 7 of 15
Enrollment Number: 03-134232-002_
Q No 6:
Write a program to check whether a character is an alphabet, digit or special character
Page 8 of 15
Enrollment Number: 03-134232-002_
Q No 7:
Write a program to calculate and print the electricity bill of a given customer. The customer
id, name and unit consumed by the user should be taken from the keyboard and display the
total amount to pay by the customer. You can check unit price from your electricity bill
including off-peak and peak hours.
Page 9 of 15
Enrollment Number: 03-134232-002_
Write down the C++ code and dry run the following problem statements.
Q No 8:
Write a program to display the cube of the number up to a given integer.
Test Data:
Input Number of terms: 5
Expected Output:
Number is: 1 and cube of the 1 is: 1
Number is: 2 and cube of the 2 is: 8
Number is: 3 and cube of the 3 is: 27
Number is: 4 and cube of the 4 is: 64
Number is: 5 and cube of the 5 is: 125
Page 10 of 15
Enrollment Number: 03-134232-002_
Page 11 of 15
Enrollment Number: 03-134232-002_
Q No 9:
Write a program to make such a pattern like a pyramid with numbers increased by 1.
Expected Output:
1
2 3
4 5 6
7 8 9 10
Page 12 of 15
Enrollment Number: 03-134232-002_
Page 13 of 15
Enrollment Number: 03-134232-002_
Page 14 of 15
Enrollment Number: 03-134232-002_
Q No 10:
Write a program to display the n terms of harmonic series and their sum.
1 + 1/2 + 1/3 + 1/4 + 1/5 … 1/n terms
Test Data:
Input the number of terms: 5
Expected Output:
1/1 + 1/2 + 1/3 + 1/4 + 1/5
Sum of Series upto 5 terms: 2.283334
Page 15 of 15