Assignment 01-2
Assignment 01-2
Assignment 01-2
CAMPUS
Instructions:
• For each question in your assignment, make a separate cpp file e.g. for question 1, make ROLL-
NUM_SECTION_Q#.cpp (23i-0001_A_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.
• Combine all your work in one folder. The folder must contain only .cpp files (no binaries, no
exe files etc.).
• Rename the folder as ROLL-NUM_SECTION (e.g. 23i-0001_A) and compress the folder as a
zip file. (E.g. 23i-0001_A.zip). Do not submit .rar file.
• All the submissions will be done on Google classroom within the deadline. Submissions other
than Google classroom (e.g. email etc.) will not be accepted.
• The student is solely responsible to check the final zip files for issues like corrupt files, viruses
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.
• Displayed output should be well mannered and well presented. Use appropriate comments and
indentation in your source code.
• Be prepared for viva or anything else after the submission of assignment.
• If there is a syntax error in code, zero marks will be awarded in that part of assignment.
• Understanding the assignment is also part of assignment.
• The AIM of this assignment is to give you practice with arithmetic, bitwise and ternary
operators. Zero marks will be awarded if advance topics (e.g., if else, loops & arrays etc.)
used. Do not use any built-in function other than pow , log (#include <cmath>) setw and
setfill (#include <iomanip>).
• Zero marks will be awarded to the students involved in plagiarism. (Copying from the
internet is the easiest way to get caught).
• Late Submission policy will be applied as described in course outline.
1|P a ge
NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES ISLAMABAD
CAMPUS
2|P a ge
NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES ISLAMABAD
CAMPUS
Whereas:
N = How long it will take to pay off a credit card loan. (float)
c = A constant factor (int : value will be 30).
b = balance (int)
p = monthly payment (int)
i = yearly interest rate/365 (float)
ln = Natural logarithm
Write a program that takes these c, b, p and i as an inputs and gives an output. Note: use cmath
library for pow and log functions.
3|P a ge
NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES ISLAMABAD
CAMPUS
4|P a ge
NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES ISLAMABAD
CAMPUS
An example of this is given below (note that all the bits in one row XORed equal to the same
Constant Bit). You must print the Key at the end. You have to find and display the key.
Input 32 bit positive number: 3584717002
1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 1 1 0 0 1 0 1 0
Constant GATE3 GATE2 GATE1
5|P a ge
NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES ISLAMABAD
CAMPUS
6|P a ge