Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question


1. Write a function called void swap with two parameters, which will receive the address
of x and y as pointer. The function should swap the value of x and y only if x is larger than
y. Print the value of x and y after the function call.


2. Write a function called double getAverage(int *array, int SIZE), where
it accept the array as pointer, and return the average of the array. Print the returned
value from this function. Always use *array rather than subscript to access the array
value.

ChangeIt_1 : 10
ChangeIt_2 : 6
ChangeIt_3 : 7
ChangeIt_4 : 8
Process exited after 0.2283 seconds with return value e
Press any key to continue .
Compner KESUUICES ompEog V DEDug STIna KESUItS a CIOSE
expand button
Transcribed Image Text:ChangeIt_1 : 10 ChangeIt_2 : 6 ChangeIt_3 : 7 ChangeIt_4 : 8 Process exited after 0.2283 seconds with return value e Press any key to continue . Compner KESUUICES ompEog V DEDug STIna KESUItS a CIOSE
#include <iostream>
using namespace std;
3E void ChangeIt_1(int n) {
n = 5;
}
void ChangeIt_2(int *n) {
*n = 6;
4
6.
7
}
99 void ChangeIt_3(int &n) {
n = 7;
}
int ChangeIt_4(int n) {
n = 8;
10
11
12
13
14
return n;
}
main(){
int *p; //declare p as pointer
int x=10, y=7, SIZE=5, data[SIZE]={1,3,2,5,4};
p=&x; //reference of x
15
16
17
18
19
20
ChangeIt_1(x);
cout « "ChangeIt_1 :
21
22
« *p <« endl;
23
ChangeIt_2(&x);
cout « "ChangeIt_2 :
24
25
« *р <« endl;
26
ChangeIt_3(x);
cout <« "ChangeIt_3 :
27
28
« *р << endl;
29
ChangeIt_4(x);
cout <« "ChangeIt_4 :
30
X =
31
« *р <« endl;
32
33
expand button
Transcribed Image Text:#include <iostream> using namespace std; 3E void ChangeIt_1(int n) { n = 5; } void ChangeIt_2(int *n) { *n = 6; 4 6. 7 } 99 void ChangeIt_3(int &n) { n = 7; } int ChangeIt_4(int n) { n = 8; 10 11 12 13 14 return n; } main(){ int *p; //declare p as pointer int x=10, y=7, SIZE=5, data[SIZE]={1,3,2,5,4}; p=&x; //reference of x 15 16 17 18 19 20 ChangeIt_1(x); cout « "ChangeIt_1 : 21 22 « *p <« endl; 23 ChangeIt_2(&x); cout « "ChangeIt_2 : 24 25 « *р <« endl; 26 ChangeIt_3(x); cout <« "ChangeIt_3 : 27 28 « *р << endl; 29 ChangeIt_4(x); cout <« "ChangeIt_4 : 30 X = 31 « *р <« endl; 32 33
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education