Q1. Have a look at the following piece of code and state as well as explain the output.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
LOVELY PROFESSIONAL UNIVERSITY
Academic Task No. 1
School : of Computer Science and Engineering
Name of the faculty member_Ms. Gauri Mathur_
Course Code: CSE202
Faculty of: Technology and Sciences
Course Title: Object Oriented Programming
Program:
Max. Marks: 30
Term:
Is Rubric Applicable: No
Date of Allotment: 26/02/2021
Date of Submission: 09/03/2021
Important Guidelines:
1. All questions in this Academic Task are compulsory.
2. It is mandatory to attempt all questions of the assignment in your own handwriting on A4 size
sheets/pages with a blue colour ink pen. Any other mode of attempt (typed or printed codes or table) except hand written/drawn will
not be accepted/considered as valid submission(s) under any circumstances.
3. Every attempted sheet/page should carry clear details of student such as Name, Registration number, Roll number, Question
number and Page number. The page numbers should be written clearly on the bottom of every attempted sheet in a prescribed format
as: for page 1; Page 1 of 4, for page 2; Page 2 of 4, for page 3; Page 3 of 4 and for page 4; Page 4 of 4, in case your
assignment/document is of 4 pages.
4. After attempting the answer(s), student needs to take photograph of each of these answer sheets/pages and needs to convert the
jpeg format images into a sequential single pdf format document (can be done with many free online available converters).
5. This PDF file should be uploaded onto the UMS interface on or before the last date of the submission.
6. Refrain from indulging into plagiarism as copy cases will be marked zero.
Q1. Have a look at the following piece of code and state as well as explain the output. [10]
i)
#include <iostream>
using namespace std;
void fun(int &ref, int sum, int total) {
ref = sum = total;
int main() (
// your code goes here
int sum = 10, total = 20;
int &ref = sum;
fun(ref, sum, total);
cout<<ref<<" "<<sum<<" "<<total;
return 0;
ii)
#include <iostream>
using namespace std;
int main() (
// your code goes here
int a = 10, b = 20;
int &ref = a;
int *p:
p= &ref;
cout<<*p;
return 0
Transcribed Image Text:LOVELY PROFESSIONAL UNIVERSITY Academic Task No. 1 School : of Computer Science and Engineering Name of the faculty member_Ms. Gauri Mathur_ Course Code: CSE202 Faculty of: Technology and Sciences Course Title: Object Oriented Programming Program: Max. Marks: 30 Term: Is Rubric Applicable: No Date of Allotment: 26/02/2021 Date of Submission: 09/03/2021 Important Guidelines: 1. All questions in this Academic Task are compulsory. 2. It is mandatory to attempt all questions of the assignment in your own handwriting on A4 size sheets/pages with a blue colour ink pen. Any other mode of attempt (typed or printed codes or table) except hand written/drawn will not be accepted/considered as valid submission(s) under any circumstances. 3. Every attempted sheet/page should carry clear details of student such as Name, Registration number, Roll number, Question number and Page number. The page numbers should be written clearly on the bottom of every attempted sheet in a prescribed format as: for page 1; Page 1 of 4, for page 2; Page 2 of 4, for page 3; Page 3 of 4 and for page 4; Page 4 of 4, in case your assignment/document is of 4 pages. 4. After attempting the answer(s), student needs to take photograph of each of these answer sheets/pages and needs to convert the jpeg format images into a sequential single pdf format document (can be done with many free online available converters). 5. This PDF file should be uploaded onto the UMS interface on or before the last date of the submission. 6. Refrain from indulging into plagiarism as copy cases will be marked zero. Q1. Have a look at the following piece of code and state as well as explain the output. [10] i) #include <iostream> using namespace std; void fun(int &ref, int sum, int total) { ref = sum = total; int main() ( // your code goes here int sum = 10, total = 20; int &ref = sum; fun(ref, sum, total); cout<<ref<<" "<<sum<<" "<<total; return 0; ii) #include <iostream> using namespace std; int main() ( // your code goes here int a = 10, b = 20; int &ref = a; int *p: p= &ref; cout<<*p; return 0
iii)
#include<iostream>
using namespace std;
class Sample (
int data;
public:
void display() {
cout<<data<cendl;
friend void fun();
};
void fun() {
Sample obj:
obj.data = 10:
obj.display();
}
int main() {
fun():
iv)
#include <iostream>
using namespace std;
int fun(int num) {
if(num % 4 == 0) {
retum 0;
return num * 4:
int main() (
// your code goes here
cout<<fun(343);
return 0;
v)
#include <iostream>
using namespace std;
class Sample {
int data;
public:
int fun(int a) {
if(!a) (
return 1;
}
retum a + fun(a / 10):
void display() {
cout<<fun(1234);
}
};
int main() {
// your code goes here
Sample obj;
obj.display();
return 0;
Transcribed Image Text:iii) #include<iostream> using namespace std; class Sample ( int data; public: void display() { cout<<data<cendl; friend void fun(); }; void fun() { Sample obj: obj.data = 10: obj.display(); } int main() { fun(): iv) #include <iostream> using namespace std; int fun(int num) { if(num % 4 == 0) { retum 0; return num * 4: int main() ( // your code goes here cout<<fun(343); return 0; v) #include <iostream> using namespace std; class Sample { int data; public: int fun(int a) { if(!a) ( return 1; } retum a + fun(a / 10): void display() { cout<<fun(1234); } }; int main() { // your code goes here Sample obj; obj.display(); return 0;
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY