Assignment+No 1
Assignment+No 1
ASSIGNMENT #1
Total Marks: 100
Due Date: Wednesday, September 12, 2018 (11:30 pm)
Instructions
1. Write the algorithm for solving the given problems using pseudo‐code.
2. Solutions should be written in docx format.
3. Solution to all the problems should begin on a new page.
4. Submit both the pseudo‐code and three dry runs corresponding to every problem
validating your solution.
5. Submit the solutions via slate.
6. Submissions via Email will not be accepted.
7. Use proper naming convention to name the file containing pseudo‐code. For example,
the file containing the pseudo‐code for first question of the first assignment should be
named as i18xxxx_assignment_1_q1.docx, replace i18xxxx with your student number.
Similarly, the third question of the assignment should be named as
i18xxxx_assignment_1_q3.docx, etc.
8. Please write your name and roll number at the beginning of each Algorithm.
9. Use MS Word for creating the solutions.
(Please discuss if you want to use something else for drafting your solution).
Plagiarism:
Plagiarism is not allowed. If found plagiarized, you will be awarded zero marks in the
assignment.
Note:
Don’t upload compressed/zip file.
Follow the given instruction to the letter, failing to do to so will result in a zero.
NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES
ISLAMABAD CAMPUS Programming Fundamentals (CS -118)
FALL 2018
Problem 1: Write an algorithm that reads two integers and outputs the largest.
Problem 2: Write an algorithm a that reads three integers and outputs the largest.
Problem 3: Write an algorithm that reads two integers and outputs them in increasing order.
Problem 4: Write an algorithm that reads three integers and outputs them in increasing
order.
Problem 5: Write an algorithm that reads two integers and outputs the smallest.
Problem 6: Write an algorithm that reads three integers and outputs the smallest.
Problem 7: Write an algorithm that reads two integers and outputs them in decreasing order.
Problem 8: Write an algorithm that reads three integers and outputs them in decreasing
order.
Problem 9: Write an algorithm that reads three integers and prints the average of these.
Problem 10: Write an algorithm that reads sides of a triangle and finds its area.
Problem 11: Write an algorithm that reads the score of a student in a subject and displays his
grade according to the following criteria:
Problem 12: Write an algorithm that reads the user’s age and then outputs “You are a child.”
If his age < 18, “You are an adult.” If age < 65, and “You are a senior citizen.” If age>= 65.
NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES
ISLAMABAD CAMPUS Programming Fundamentals (CS -118)
FALL 2018
Problem 13: Write an algorithm that simulates a simple calculator. It reads two integers and a
character. If the character is a +, the sum will be printed; if it is a -, the difference will be
printed; if it is a *, the product will be printed; and if it is a /, the quotient will be printed.
Problem 14: Write an algorithm that calculates and prints circumference of a circle.
Problem 15: Write an algorithm that calculates and prints mode, median and standard
deviation of 5 values.
Problem 16: Write an algorithm that take values of length and breadth of a rectangle from user
and check if it is square or not.
Problem 17: A shop will give discount of 10% if the cost of purchased quantity is more than
1000.
Ask user for quantity
suppose, one unit will cost 100.
Judge and print total cost for user.
Problem 18: A student will not be allowed to sit in exam if his/her attendence is less than
75%.
Take following input from user
Number of classes held
Number of classes attended.
And print
percentage of class attended
Is student is allowed to sit in exam or not.
Problem 20: A 4-digit number is entered through keyboard. Write an algorithm to print a new
number with digits reversed as of orignal one. E.g.-
INPUT : 1234 OUTPUT : 4321
INPUT : 5982 OUTPUT : 2895
Use the quotient operator / and the remainder operator % to extract the digits from the
integer. For example, if n is the integer 876, then n/100 is 8 while n%100 is 76.
NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES
ISLAMABAD CAMPUS Programming Fundamentals (CS -118)
FALL 2018
Problem 21: Write an algorithm that will ask the user to enter the amount of a purchase and
compute the state and county sales tax. Assume the state sales tax is 5 percent and the county
sales tax is 2.5 percent. The Algorithm should print the amount of the purchase, the state sales
tax, the county sales tax, the total sales tax, and the total of the sale.
Problem 22: Write an algorithm for printing a sequence up to input number N. E.g., for N =
10, the output should be: 1, 2, 3 …. 10
Problem 23: Write an algorithm for printing an odd sequence up to input number N. E.g., for
N = 10, the output should be 1, 3, 5 ……. 9
Problem 24: Write an algorithm for printing an even sequence up to input number N. E.g., for
N = 10, the output should be 0, 2, 4 ……. 10
Problem 25: Write an algorithm for printing the table of given input number N. E.g., for N =
22, the output should be 22, 44, 66 …….. 220
Problem 26: Write an algorithm that reads two numbers and either “multiple” or “not” if one
of the number is a multiple of the other.