You are on page 1of 4

National University

of Computer & Emerging Sciences-Faisalabad

National University of Computer and Emerging Sciences

Assignment # 02

Programming Fundamentals

Fall 2021

Deadline: 05:00. p.m.


20th October 2021

Department of Computer Science


National University
of Computer & Emerging Sciences-Faisalabad

Note: Carefully read the following instructions.

1. Make a word document with the convention “ROLLNO_SECTION_LABNO” and put all
your C++ source code in it.
2. After every question paste a screenshot of your working code below the source code in the
document file.
3. At the end, when you are done with your lab tasks, make your submission on Google
classroom.

TASKS
1. Write a C++ program that prompts the user to input a number. The program should then
output the number and a message saying whether the number is positive, negative, or zero.

2. Write a C++ program which takes a 5-digit number from the user and checks if it is
palindrome or not and then prints appropriate message. (A palindromic number is a number
(such as 16461) that remains the same when its digits are reversed. for example 16461
remains same even after the digits are reversed)

3. Write a C++ to display day name when user input the day number. For example:
Input: 3 Output: Wednesday

4. Write a C++ program to input electricity unit charges and calculate total electricity bill
according to the given condition:
 For first 50 units Rs. 0.50/unit
 For next 100 units Rs. 0.75/unit
 For next 100 units Rs. 1.20/unit
 For unit above 250 Rs. 1.50/unit
 An additional surcharge of 20% is added to the bill
a) Implement this task using if else statement
b) Perform the same task using switch statement

5. Uzair and Usman are looking to buy a house in a new development. After looking at various
models, the three models they like are colonial, split-entry, and single-story. The builder gave
them the base price and the finished area in square feet of the three models. They want to
know the model(s) with the least price per square foot. Write a C++ program that accepts as
input the base price and the finished area in square feet of the three models. The program
outputs the model with the least price per square foot that user asks.
National University
of Computer & Emerging Sciences-Faisalabad
6. Write a C++ program to check whether an entered character is lowercase (a to z) or uppercase
(A to Z).Hint: Use ASCII values. Implement this task using ternary operator.

7. Write a C++ program that will take grade of a student as input and output the range of
percentage he/she may have. Following are the grading criteria: You can assume letter+ grade
as lower case character (for example take A+ grade as a).

Sample output
Input Grade: b
This grade lies in the range: 70<= M<80

8. Implement a restaurant system that sells only burger ($30) fries ($10) and drinks ($5) ask the
user what’s the order then quantity of the order now add the final output in an integer variable
for each order (hint price * quantity). Then display the bill and ask for payment take payment
and display the change to the user if the change is negative then show invalid amount.

9. You have to create a C++ program which takes quiz of a student to check his/her knowledge
about arithmetic, logical and relational operations.
 You are provided with a list of expressions below.
 Store the result of these expressions in variables with appropriate data types.
 Prompt the user these expressions one by one and then take answers as inputs.
 Compare each specific user entered answer with values in the corresponding variables.
 Maintain the score of the student and output it when the quiz ends. For each correct answer
the student gets one. Use unary operator for it.
Expressions
Bool type:
I. ( !0 )
II. ( ( !1 || !0 ) && ( !( 1 && 0 ) )
III. ( 5 + 4 < 3 && 7 + 3 <= 20 )
IV. ( ‘a’ !=’b’ – 1 )
V. ( ( 3 % 2 ) * 1 == 1 && 5 * ( 3 % 3 ) == 0 )
National University
of Computer & Emerging Sciences-Faisalabad
VI. “Ali” >= “Noor”
VII. “123” >= “456”
int/Float:
I. (9/3%3)+(3*4/4)
II. ((3–2/2)*7%7
Char:
I. ‘a’ + ( 5 % 5 ) * 4
II. ‘Z’ – 5 + ( 30 / 6 )

Guidelines
 A single violation of guideline will lead to Zero mark in your assignment.
 The Questions should be in order, otherwise -5.
 You can submit your assignment late, within three days after your due date
with 30% marks deduction per day.
 You will have maximum marks if you have done the entire tasks.
 Deadlines should be kept in mind.
 This is an individual assignment. PLAGARISM IS NOT ACCEPTABLE!

You might also like