You are on page 1of 3

NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES

ISLAMABAD CAMPUS
CS-118 Programming Fundamentals - SPRING 2020
ASSIGNMENT- 2
Section (B, C, D, E and F)
Due Date: Friday 14th February 2020 at 11:59 pm on Google Class Room

Instructions:
1. Assignments are to be done individually. You must complete this assignment by yourself. You cannot
work with anyone else in the class or with someone outside of the class. The code your write must be your
own and you must have understanding of each part you code. You are encouraged to get help from the
instructional staff through email, on google classroom or individually visiting their respective offices.
2. The AIM of this assignment is to give you practice with bitwise and arithmetic operator’s (chapters 2 and 3
of textbook).
3. Use appropriate data types and operation for each problem.
4. No late assignments will be accepted.
5. Displayed output should be well mannered and well presented. Use appropriate comments and indentation
in your source code.
6. Plagiarism:
Plagiarism is not allowed. If found plagiarized, you will be awarded zero marks in the assignment.
Repeating such, an act can lead to strict disciplinary actions and failure in course.

Submission Guidelines:
Dear students we will be using auto-grading tools, so failure to submit according to the below
format would result in zero marks in the relevant evaluation instrument.
i) For each question in your assignment, make a separate cpp file e.g. for question 1, make q1.cpp
and so on. Each file that you submit must contain your name, student-id, and assignment # on top
of the file in comments.
ii) Combine all your work in one folder. The folder must contain only .cpp files (no binaries, no
exe files etc.).
iii) Run and test your program on a lab machine before submission.
iv) Rename the folder as ROLL-NUM_SECTION (e.g. 19i-0001_B) and compress the folder as a
zip file. (e.g. 19i-0001_B.zip).
v) Submit the .zip file on Google Classroom within the deadline.
vi) Submission other than Google classroom (e.g. email etc.) will not be accepted.
vii) The student is solely responsible to check the final zip files for issues like corrupt file, virus
in the file, mistakenly exe sent. If we cannot download the file from Google classroom due to any
reason it will lead to zero marks in the assignment.
1. Suppose a country have currency notes of amount 600, 300, 150, 50, 30, 5
and 1. Write a C++ program which accepts amount as input in integer and
display total number of Currency Notes of Rs. 600, 300, 150, 50, 30, 5 and
1.

For example: when user enter a number, 1077 the results would be like this.

Currency Note: Number


600 :1
300 :1
150 :1
50 :0
30 :0
5 :5
1 :2

2. Write a C++ program to calculate multiplication of two four-digit integers’


multiplications by using Karatsuba method.

3. Write a C++ program that converts Decimal value 225 to equivalent Octal,
Binary and Hexadecimal values.

4. Write a C++ program which accepts days as integer and display total
number of years, months and days in it. Suppose Year =365days and month
= 30 days.
For example: If user input as 856 days the output should be 2 years 4
months 6 days.

5. Write a program, which takes short (16-bit integer) value as an input from
user and multiply it with 63. Remember, you can only use bitwise operators for
this problem.

6. In cryptography XOR cipher is one of the simplest and powerful encryption


scheme. XOR cipher is part of other more complex encryption schemes. In
this problem, you have to implement XOR cipher for 64-bit encryption and
decryption. For this purpose take two integers of 64-bit length from user one
for plaintext and other for Key. You have to implement encryption and
decryption of plaintext by using XOR operator.
7. In order to save disk space Time field in the directory entry is 2 bytes long.
Distribution of different bits which account for hours, minutes and seconds is
given below:

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
H H H H M M M M M M S S S S S S

Write a C++ Program that take input two-byte time entry and appropriately
separates hours, minutes and seconds using suitable bitwise operators.
Think cleverly. The program executes in following manner:

Enter a two-byte Time Value: 4879

Time is 1 hrs 12 mins 15 secs

Enjoy Codding because it is a great fun (Bill Gates) 😊

Start your codding now!

You might also like