PF Concepts + Basic Class

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

UNIVERSITY OF MANAGEMENT AND TECHNOLOGY

Department : IT
Course Title : Object Oriented Programming
Course Code : CC1022
Session : Spring 2021
Section : Y3
Quiz No. : 01
Roll No. :

PF Concepts

1. Write a program following the instructions below.


1. Declare an integer variable Sum1.
2. Declare two integer variables A and B and take input in them.
3. Declare three integer pointers Pointer1, Pointer2, and Pointer3.
4. Assign the address of variable A to pointer variable Pointer1.
5. Assign the address of variable B to pointer variable Pointer2.
6. Subtract the value of a variable pointed to by Pointer1 from the value of variable pointed to by
Pointer2 (You should not use variables A and B in this statement). Assign the result of subtraction
to variable Sum1.
7. Assign the value of pointer variable Pointer1 to pointer variable Pointer3.
8. Assign the value of pointer variable Pointer2 to pointer variable Pointer1.
9. Assign the value of pointer variable Pointer3 to pointer variable Pointer2.
10. Print the value of variable Sum1.

2. Specify output of the following in the space provided.


#include <iostream>
using namespace std;
int main ()
{
//Assume any value for the addresses involved in this code and specify your assumption //clearly
as a comment or side note
int x; int y;
int *p = &x; int *q = &y;
*p=5; *q=10;
cout << x << “ ” << y << endl;
cout << p << “ ” << q << endl;
cout << *p << “ ” << *q << endl;
cout << &x << “ ” << &y << endl;
return 1;
}
3. Identifying classes from textual requirements
Assume you have to design a simple online processing system in which customers place an order for
a product. There are multiple types of products available in the system. The system also maintains a
record about the available suppliers for each product that supplies the product to customer once the
order is finalized. When the customer places an order, the system (or manager) verifies the order to
check if payment details mentioned by the customer is valid or not. If the details are validated
successfully then the system finalizes the order otherwise rollbacks the order and inform the customer
about it. When a customer selects the product for purchase and initiate an order, then the system
should check the availability of that product in inventory. If the product is not found then the system
should inform the customer about product's unavailability and he/she should not be able to proceed
with this order. Once the order has been successfully placed, customer should be able to track the
order.
Identify the valid classes, their attributes and functions. Report the class attributes and
functions separately using UML representation that we learnt in class (rectangular
representation).

You might also like