PF _ Assignment 3 Manual
PF _ Assignment 3 Manual
Assignment No. 3
Programming Fundamentals
CS1002
Fall 2022
1|Page
Submission Instructions:
All problems must be solved by following the order and submitted in .cpp file in zip folder and
also have to submit the word file (.docx) otherwise marks will be deducted.
Printed assignment will get you zero marks.
This is an individual assignment.
Plagiarism is strictly prohibited.
2|Page
Assignment Tasks
1. Write a C++ code that takes an integer n as an input from the user which is greater than 5 else print
Incorrect Input! If n multiple of 5 then take a variable temp = n/2 and print temp times n else take a
variable temp = n/3 and print temp times n.
Example:
Input: 10
Output: 1010101010
Input: 13
Output: 13131313
Input: 4
Output: Incorrect Input!
2. Write a C++ program that takes an integer type variables from the user and output the following
things;
1. Count the number of digits in that number i.e. 5
2. Reverse this number and store back into the original variable.
Example:
3. Ask user to enter a character and tell whether it is large (>=’A’ and <=’Z’) alphabet or small alphabet
after that save this code in a file of 01_BMI.cpp and perform the following task: (Body Mass Index
Calculator) Following is formula to calculate BMI: BMI= weightInKilograms/ (heightInMeters2).
User will enter his weight in Kilograms and height in meters and the BMI of the user and display
following:
1. Display “You are Underweight” if BMI is less than 13.5
2. Display “You are Normal” if BMI is between 13.5 and 18.9
3. Display “You are Overweight” if BMI is between 19.0 and 28.9
4. Display “You are Obese” if BMI is greater than 29.9
Use and (&&) operator for writing multiple conditions in the if statement.
3|Page
4. Write a code that take 2 inputs from the user and initialize a variable of type Boolean. If the inputs
numbers are multiple of each other than Boolean variable will be true else false. If Boolean variable
is true print True! They are multiples of each other. else False! They are not multiple of each
other.
5. Write a code that input a number from user and print it into words.
Example:
Input: 8745
Output: Eight Seven Four Five
6. First print the even in 1-100 on a separate line and then odd numbers from 1-100 in same line with
tab space. Save this code with a filename as 06_Palindrome.cpp
7. Write a program to prompt user to enter month and year. Your program should display the number of
days in the month of that year.
Example:
8. Write a code that take a binary input from the user and contains more than 6 and less than 10 digits
and counts the total 1’s present. If the digits are less than 6 it will print Digits are less than six and if
the digits are greater than 10 it will print Digits are greater than 10. In case if the user has entered a
number that is not a Binary number than it will print Incorrect Input! It is not a Binary Number.
Example:
Input: 10011001
Output: 4 zeros
4|Page
9. In this question, find the Sum of following exponential series up to N terms. Ask the user to input N and X
from user. You are not allowed to use any built-in functions, custom functions structure and the libraries.
Hint: you can calculate the power and factorial in a separated loops and use them to find the sum!
10. Write a C++ Program that is using a sentinel control while loop statement and if statement to write a
program that can be used at a department store’s register the records the number of customers who
spent between $0.00-$200.00, and the number of customers who spent between $200.01-$800.01 and
the number of customers who spent $800.01 or more. At the end of the day, the program will print
out the number of customers in each of categories and total spending in each categories.
5|Page
11. An organization wanted to give bonus to his employees in three situations
a) For either gender, if age is more than 30 and basic pay is more than 25000 then bonus is
25% of basic pay
b) For male, if age is less than 30, and basic pay is more than 21000 then bonus is 17% of
basic pay
c) For female employees, if age is less than 25, and basic pay is more than 18000 then bonus is
13% of basic pay
In any other condition organization will not give bonus
Program: Input- basic pay, gender, age, and calculate the bonus for employees.
6|Page