Assifnment 1-PF
Assifnment 1-PF
Dear students we will be using auto-grading tools, so failure to submit according to the below
i. 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.
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. 23i-0001_A) and compress the folder as a zip file.
(e.g. 23i-0001_A.zip). do not submit .rar file.
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.
viii. Displayed output should be well mannered and well presented. Use appropriate comment and
indentation in your source code.
ix. Total Marks: 20.
x. The AIM of this assignment is to give you practice with bitwise and arithmetic operator’s (chapters
2 and 3 of textbook). Zero marks will be awarded if advance topics (e.g., if, if else or loops etc.)
used. Do not use any built-in function other than pow function (#include <cmath>).
xi. ii. If there is a syntax error in code, zero marks will be awarded in that part of assignment.
xii. Your code must be generic.
Deadline:
Deadline to submit assignment is 22nd February 2024 11:59 PM. You are supposed to submit your
assignment on GOOGLE CLASSROOM (CLASSROOM TAB not lab). Only “.ZIP” files are acceptable. Other
formats should be directly given ZERO. Correct and timely submission of the assignment is the responsibility
of every student, hence no relaxation will be given to anyone. Late Submission policy will be applied as
described in course outline.
Tip: For timely completion of the assignment, start as early as possible.
Plagiarism: Plagiarism is not allowed. If found plagiarized, you will be awarded zero marks in the assignment
(copying from the internet is the easiest way to get caught ).
Note: Follow the given instruction to the letter, failing to do so will result in a zero.
Question 1 [5 Marks]
Write a C++ program to implement the following algebraic expressions to calculate and display the values of
a,z,y,g,c. Other variables in the program will be input by the user:
Question 2 [5 Marks]
Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase:
• The number of shares that Joe purchased was 1,000.
• When Joe purchased the stock, he paid $45.50 per share.
• Joe paid his stockbroker a commission that amounted to 2% of the amount he paid
for the stock.
Two weeks later Joe sold the stock. Here are the details of the sale:
• The number of shares that Joe sold was 1,000.
• He sold the stock for $56.90 per share.
• He paid his stockbroker another commission that amounted to 2% of the amount he received for
the stock.
Write a program that displays the following information:
• The amount of money Joe paid for the stock.
• The amount of commission Joe paid his broker when he bought the stock.
• The amount that Joe sold the stock for.
• The amount of commission Joe paid his broker when he sold the stock.
• Display the amount of profit that Joe made after selling his stock and paying the two
commissions to his broker. (If the amount of profit that your program displays is a
negative number, then Joe lost money on the transaction.)
Question 3 [5 Marks]
Write a program, which takes two 8-bit integers value and add them. Remember, you can only use bitwise
(& | ^ ~ etc.) or assignment (=) operators for this problem.
Example01:
Enter number 1: 25
Enter number 2: 63
Output: 88
Example02:
Enter number 1: 15
Enter number 2: 7
Output: 22
Question 4 [5 Marks]
Write a program to output the given patterns using I/O manipulator appropriately. You will input a character
from the user and will draw the following pattern of character using that variable.
Note: You cannot use any string literals containing white spaces in cout and can use any character as input
to draw the pattern instead of *