subject

#include using namespace std; void swap1(int n1, int n2) { int temp = n1; n1 = n2; n2 = temp; } void swap2(int& n1, int& n2) { int temp = n1; n1 = n2; n2 = temp; } void swap3(int* p1, int* p2) { int temp = *p1; *p1 = *p2; *p2 = temp; } void swap4(int* &p1, int* &p2) { int* temp = p1; p1 = p2; p2 = temp; } int main() { int num1 = 1; int num2 = 2; cout << "Before invoking the swap1 function, num1 is " << num1 << " and num2 is " << num2 << endl; swap1(num1, num2); cout << "After invoking the swap1 function, num1 is " << num1 << " and num2 is " << num2 << endl; cout << "Before invoking the swap2 function, num1 is " << num1 << " and num2 is " << num2 << endl; swap2(num1, num2); cout << "After invoking the swap2 function, num1 is " << num1 << " and num2 is " << num2 << endl; cout << "Before invoking the swap3 function, num1 is " << num1 << " and num2 is " << num2 << endl; swap3(&num1, &num2); cout << "After invoking the swap3 function, num1 is " << num1 << " and num2 is " << num2 << endl; int* p1 = &num1; int* p2 = &num2; cout << "Before invoking the swap4 function, p1 is " << p1 << " and p2 is " << p2 << endl; swap4(p1, p2); cout << "After invoking the swap4 function, p1 is " << p1 << " and p2 is " << p2 << endl; return 0; }

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:00
Which function key is used to enable the spelling & grammar function in a word processing program such as microsoft word?
Answers: 3
question
Computers and Technology, 22.06.2019 11:00
in 2007, floridians died in alcohol-related collisions.a.  501b.  1,051c.  5,015d.  10,839
Answers: 1
question
Computers and Technology, 22.06.2019 23:50
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a – b1 0 a + b1 1 a – 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form.you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used.hint: design a combinational logic circuit to modify the input b and the “carry input” of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
To check whether your writing is clear , you can
Answers: 2
You know the right answer?
#include using namespace std; void swap1(int n1, int n2) { int temp = n1; n1 = n2; n2 = temp; } void...
Questions
question
Geography, 21.08.2019 21:00
question
Chemistry, 21.08.2019 21:00