You are on page 1of 3

Mini Project 1 (MP 1)

Object Oriented Programming,


CS/SE, SST, UMT
Student’s Name:_________________ Student Id: __________________ Total Marks: 200
CLO3: Model a solution for a given problem using object-oriented principles

Submission Instructions: Upload the folder (with your ID as its name) containing your source files and executable file on
Moodle by the deadline. 5% marks for Indentation, 5% marks for Naming and 5% marks for Commenting, 5% marks
corresponds to using Discussion form (at least 1 query or reply to 1 query)

1) (a) Write a program that takes input ‘n’ from the user and find prime numbers from 1 to
n. (if n<3 then it is invalid input)

2) Write a C program to generate the following series.


2, 4, 6, 4, 4.666, 4.888, 4.518 …..
How many numbers you want to generate?
Input: 6
Output:
2, 4, 6, 4, 4.666, 4.888
• The 4th number is taken by adding first three numbers and then dividing by 3.
• The nth number is taken by adding (n-3)(n-2)(n-1) and then dividing by 3.

3) Write a code that takes two values m and n from user and find mn .
Sample Output:
Input: m=2 and n=5
Output: answer is 32

4) (a) Write a C++ program which should find the Greater Common Divisor (GCD)
between two numbers.
Sample Output
Input: x=20, y=50
Output:
The greatest common divisor is 10.

(b) Write a C++ program which should find the Least common multiple (LCM) between
two numbers.
Syed Farooq Ali, farooq.ali@umt.edu.pk OOP Page 1
Sample Output
Input: x=4, y=14
The least common multiple is 28.
5) Write a code which takes size from user and draw the following shape of that size
(a) Sample Output
Input: 5
*
* *
* *
* *
* *

(b) Sample Output


Input: 4
* *
* *
* *
*

(c) Sample Output


Input: 5
* *
* *
* * *
** **
* *

6) Write a code that takes two integer arrays A and B of same size from the user. Pass the
arrays in new function. Find the multiplication of both Arrays.
A={1,2,3}, B={2,3,4}
Resultant_Array={2,8,7,8,2}
Note: Arrays is like a number

7) (a) Take a number from user and check whether it is Armstrong number or
not?
Armstrong number is taken by taking cube of its each digit. If answer is
equal to the number then it is Armstrong number.
Sample Output
Input=371
33 + 7 3+13= 371
Output= Yes it is Armstrong number

Syed Farooq Ali, farooq.ali@umt.edu.pk OOP Page 2


8) Take a string from the user, check if any upper case alphabet exist. Convert all upper case
alphabets into lower case alphabets
Note: Do not use builtin function of a string
Inputstr[]: “My first lab in OOP”
Output: my first lab in oop.

9) Repeat question 8 using a builtin function

10) Assume a simple login system in which user can provide its password as a string and your
program will validate its password. The password should be from 8 to 16 characters long. The
password can contain only alphabets, digits and special symbols (@, $, %, &, *). The password
must have one upper case alphabet, one digit and one special symbol. The password cannot
start from a special symbol.

Sample output:
Ex1: Ex 4:
Password : Abcxyz123 Password: help_007
Output: Invalid, No special symbol Output: Invalid, Must have one upper case

Ex2: Ex. 5
Password: @Ab123456 Password: Help_007
Output: Invalid, Password Cannot start with Output: Valid
special symbol
Ex 3: Ex. 6
Password: 123_Ah Password: 007_Ahmed_$%@
Output: Invalid, Length of password must Output: Valid
from 8 to 16

11) Take string From User and Reverse it Word By Word.


Inputstr[]: “My first lab in OOP”
Output: OOP in lab first My.
Note: Using tokenize method.

Syed Farooq Ali, farooq.ali@umt.edu.pk OOP Page 3

You might also like