Q1: Write a C++ program to create a header have a function that add two numbers. Then call the function in the main code and use it to add the following numbers and display the results on the screen: a) 3 5 b) 9 Q2: What is the output for the following codes: 1- a) 2 6 7 8 c) 2 6 7 int arr[4]= {2, 6, 7, 8}; for (int i= 3; i>=0; i--) cout<

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
Q1: Write a C++ program to create a header have a function that add two numbers.
Then call the function in the main code and use it to add the following numbers
and display the results on the screen:
a)
3 5
9
b)
Q2: What is the output for the following codes:
1-
int arr[4]= {2, 6, 7, 8};
for (int i= 3; i>=0; i--)
cout<<arr[i] <<“ ";
a) 2 6 7 8
c) 2 6 7
b) 7 8 2 6
d) 8 7 6 2
2-
int arr[4]= {10, 5, 7,9};
for (int i= 0; i<2; i++)
cout<<arr[i]<< " ";
a) 10 5
) 10 5 7 9
b) 10 5 7
d) 10 5 9
3-
a) 1 5 7 9
c) 2 6 8 10
int arr[4]= {1, 5, 7, 9};
for (int i= 0; i<4; i++)
cout<<arr[i] + 1 <* ";
b) 9 7 5 1
d) 1 1 5 7 9
4 -
a) 10 3 6
c) 12 5
int arr[4]= {12, 5, 8, 4};
for (int i= 0; i<3; i++)
cout<<arr[i] -2 <“ ":
b) 10 3 6 2
d) 12 5 8
5 -
b) 6 12 15
d) 2 4 5 3
int arr[4]= {2, 4, 5, 3}3;
for (int i= 0; i<4; i++)
cout<<arr[i] * 3 « “ ":
a) 2 4 5 33
c) 6 12 15 9
6 -
int arr[4]= {1, 5, 7, 9};
for (int i= 0; i<4; i++)
cout<<arr[2] <<" ";
a) 5
c) 7
b) 5 5 5 5
d) 7 777
7-
a) 36 25 4 1
c) 36 25
int arr[4]= {6, 5, 2, 1};
for (int i= 0; i<=2; i++)
cout<<arr[i] * arr[i] << “ “;
b) 36 25 4
d) 6 5 2 1
Transcribed Image Text:Q1: Write a C++ program to create a header have a function that add two numbers. Then call the function in the main code and use it to add the following numbers and display the results on the screen: a) 3 5 9 b) Q2: What is the output for the following codes: 1- int arr[4]= {2, 6, 7, 8}; for (int i= 3; i>=0; i--) cout<<arr[i] <<“ "; a) 2 6 7 8 c) 2 6 7 b) 7 8 2 6 d) 8 7 6 2 2- int arr[4]= {10, 5, 7,9}; for (int i= 0; i<2; i++) cout<<arr[i]<< " "; a) 10 5 ) 10 5 7 9 b) 10 5 7 d) 10 5 9 3- a) 1 5 7 9 c) 2 6 8 10 int arr[4]= {1, 5, 7, 9}; for (int i= 0; i<4; i++) cout<<arr[i] + 1 <* "; b) 9 7 5 1 d) 1 1 5 7 9 4 - a) 10 3 6 c) 12 5 int arr[4]= {12, 5, 8, 4}; for (int i= 0; i<3; i++) cout<<arr[i] -2 <“ ": b) 10 3 6 2 d) 12 5 8 5 - b) 6 12 15 d) 2 4 5 3 int arr[4]= {2, 4, 5, 3}3; for (int i= 0; i<4; i++) cout<<arr[i] * 3 « “ ": a) 2 4 5 33 c) 6 12 15 9 6 - int arr[4]= {1, 5, 7, 9}; for (int i= 0; i<4; i++) cout<<arr[2] <<" "; a) 5 c) 7 b) 5 5 5 5 d) 7 777 7- a) 36 25 4 1 c) 36 25 int arr[4]= {6, 5, 2, 1}; for (int i= 0; i<=2; i++) cout<<arr[i] * arr[i] << “ “; b) 36 25 4 d) 6 5 2 1
Expert Solution
steps

Step by step

Solved in 2 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