PF - Assignment 1
PF - Assignment 1
FAISALABAD CAMPUS
Department of SE / IT
Assignment 1 (CLO-1)
FALL-2024 Marks: 10
Class: BSSE-1st (A&B) Course: Programming Fundamental
Note: A hand written neat & clean solution file attempted on assignment pages will be submitted to
th
CR or GR (in case of their absence directly to my office) during university time till Monday dated 14 ,
October 2024 (1:45 p.m.). However, solution files after marking will be uploaded on LMS as
early as possible once returned to you.
Question 1:
Part A: Develop an algorithm and model a flowchart that will read the Length and Width of a
rectangle and calculate its area.
Part B: Develop an algorithm and model a flowchart for a program that finds the average of five
numbers.
Page 1 of 3
National University of Modern Languages
FAISALABAD CAMPUS
Department of SE / IT
Assignment 1 (CLO-1)
Question 2:
Part A: Develop a C++ program to calculate the bonus amount for an employee based on his
grade and display his total salary. Prompt the user to input the grade of the employee and their
basic salary. Calculate the bonus amount according to different grades and display the total
salary including the bonus. If the grade will be from 1 to 10 then 15% bonus will be added in his
basic salary, but if the grade will be from 11 to 16 then 10% bonus will be added and if the grade
will be from 16 to 22 then 7% bonus will added in salary.
Part B: Solve the given expressions using the concept of operator precedence in C++:
i. 10 * (5 + 3) - 6 / 2
ii. (10 - 4) * 2 / (3 + 1)
iii. 2 + 3 * 4 / 2 - (4 % 3)
iv. 5 * (++a - b--), where a = 3 and b = 2
v. 20 / (4 * 2) + (5%3)
Page 2 of 3
National University of Modern Languages
FAISALABAD CAMPUS
Department of SE / IT
Assignment 1 (CLO-1)
Question 3: Your task is to identify and correct the errors in the provided C++ code. The
program is intended to that checks if a given year is a leap year.
Instructions:
#include <iostreem>
#using namespaces std;
int main() {
int year;
cout << "Enter a year: ";
cin >> years;
if (year % 4 = 0)
if (year % 100 == 0)
if (year % 400 == 0)
cout << year << " is a leap year." << endl;
else
cout << year << " is not a leap year." << endl;
else
cout << year << " is a leap year." << endl;
else
cout << year << " is not a leap year." << endl;
return 0
}
Page 3 of 3