0% found this document useful (0 votes)
46 views4 pages

Oop Week 3

This document contains 5 questions about C++ structures. Question 1 asks to write a program to calculate the distance between two points given as (x,y) coordinates. Question 2 asks to write a program to add and multiply two matrices. Question 3 asks to define a student record structure with attributes for first name, last name, and score. Question 4 asks to pass the student structure to a display function. Question 5 asks to create a nested structure with an Address structure nested within an Employee structure and write a program to give a raise if salary is less than $50,000.

Uploaded by

ayaan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views4 pages

Oop Week 3

This document contains 5 questions about C++ structures. Question 1 asks to write a program to calculate the distance between two points given as (x,y) coordinates. Question 2 asks to write a program to add and multiply two matrices. Question 3 asks to define a student record structure with attributes for first name, last name, and score. Question 4 asks to pass the student structure to a display function. Question 5 asks to create a nested structure with an Address structure nested within an Employee structure and write a program to give a raise if salary is less than $50,000.

Uploaded by

ayaan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Week #3 (Structures

Q #1:
Write a program to compute the length of the line segment connecting two points. For input the
two numbers representing each point are entered in the form (x,y). The parentheses and
comma are read as character data and then discarded.
The distance between any two points is given by taking out the square root of the formula d=
(x2-x1)2 + (y2-y1)2 . In C++ the square root is evaluated by the function (operation) sqrt() that
is declared in the file math.h.

Input:
Output:
Q #2. Take two matrix M1 and M2 as an input and perform the addition and multiplication of
these two matrices.

Input:
Output:
Q.3 Write a program that define structure to maintain student records, structure student should be
consisting of the following attributes.
1. Student first name (max 20 characters)
2. Student last name (max 20 characters)
3. Student scores (float/double) e.g 85.4

Input:
Output:

Q.4. Pass the structure define in Q.3 to some function to move to display.
Input:
Output:
Q.5 Create nested structure. Firstly, define Address structure and then call address
Structure in Employee Structure and program will give some raise in salary, if it is less than 50000
Address (house no, city, pin code)
Employee (empid,name,salary,address)

Input:
Output:
Input:
Output:

You might also like