Question
C++
4. What is a driver program? 43. Consider the following function and code segment. void Onet int first, int& second first 17 secondfirst 1 int main) // other code int j4; int k3; One(j, k) // other code .. After the call to OneGi, k); what are the values ofj and k?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Driver program:

Driver program is just a program that uses the class or algorithm that you're developing. It's primarily used for testing your code while you develop it.

Stub program:

A stub is a controllable replacement for an Existing Dependency in the system. By using a stub, you can test your code without dealing with the dependency directly.

code

====================================

#include <iostream>

using namespace std;
void One(int first ,int & second)
{
first = 17;
second = first + 1; //here k is added with 17 -->17+1=18.
}
int main()
{
int j = 4;
int k = 3;
One(j,k);
//Here j is passed by value and k is passed by reference
//So the value of j remains same even after the function calling and value of k changes
cout<<"j value: "<<j<<"\nK value:"<<k;
}

=============================================

Your Code 1 #include <iostream> 3 using namespace std; 4 void One(int first ,int & second) first17; second first 1; //here k is added with 17 --17+1-18 9 int main) 12 13 14 15 16 17 int j-4 int k-3; One(j,k) //Here j is passed by value and k is passed by reference //so the value of j remains same even after the function calling and value of k changes cout<cj value : -<cj<<\nk value : <ck; Interactive mode D OFF Focus View: D OFF VersionGCC 8.1.0 CommandLine Arguments Stdin Inputs O Execute Save My Projects Recent Collaborate FAQ More Options Result... CPU Time: 8.0 sec(s), emory: 3212 kilobyte(s) compiled and executed in 1.899 sec(5) j value: 4 K value:18 Activate Windows Go to PC settings to activate Windows.

happy to help you

please upvote and comment for doubts

Add a comment
Know the answer?
Add Answer to:
C++ 4. What is a driver program? 43. Consider the following function and code segment. void...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 62 Consider the following code: void Pancake(int x, int& y, int z); void Waffle(int& x,...

    QUESTION 62 Consider the following code: void Pancake(int x, int& y, int z); void Waffle(int& x, int& y); int Doughnut(int y, int z); int main( ) {             int a = 1;             int b = 2;             int c = 3;             int d = 4;             Pancake(a, b, c);             Waffle(b, c);             Pancake(d, c, b);             d = Doughnut(b, a);             return 0; } void Pancake(int x, int& y, int z) {             y += 3;            ...

  • Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO:...

    Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO: 1) Add the typedef here: 5// TODO: 2) Modify the parameter of repeat to add irn the function pointer for the function to be called repeatedly: 8 void repeat (int times) for (int k 0; k < times; ++k) 12 // TODO: 3) Add the call to the function pointer here: 14 15 17 void test (void) 18 printf("Test!\n"); 19...

  • 4. Consider the following C program: (2 points) int fun( int *j){ + 11; return 9;...

    4. Consider the following C program: (2 points) int fun( int *j){ + 11; return 9; } void main(){ int k 2; k + fun( &k); k What is the value of k after the assignment statement in main, assuming operands are evaluated left to right. operands are evaluated right to left. Please, also explain how you got the values in detail.

  • (10pts).   Consider the following: void fun1(void); void fun2(void); void fun3(void); void main() {    Int a,b,c;...

    (10pts).   Consider the following: void fun1(void); void fun2(void); void fun3(void); void main() {    Int a,b,c;    … } void fun1(void){    Int b,c,d;    … } void fun2(void){    Int c,d,e;    … } void fun3(void){    Int d,e,f;    … } Given the following calling sequences and assuming that dynamic scoping is used. What variables are visible during execution of the last function called? Include with each visible variable the name of the function in which it was...

  • Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void)...

    Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void) { x = x + 2; y = y + 4; } void bar(void) { int x = 10; y = y + 3; foo( ); cout << x << endl; cout << y << endl; } void baz(void) { int y = 7; bar( ); cout << y << endl; } void main( ) { baz( ); } What output does this program...

  • programming languages in #f language QUESTION 4 Consider the following skeletal C program: void funi(void); /*...

    programming languages in #f language QUESTION 4 Consider the following skeletal C program: void funi(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /* prototype */ void main() { int a, b, c; void fun1(void) { int b, c, d; void fun2 (void) { int c, d, e; void fun3(void) { int d, e, f, Assuming that dynamic scoping is used, what variables are visible during execution of the last function called in following calling sequence: main calls...

  • QUESTION 25 Examine the following program segment. Assuming the array table has values in it, what...

    QUESTION 25 Examine the following program segment. Assuming the array table has values in it, what is the correct outcome? double table [10] [2], sum=0.0; int i, j, nrows=10; for(i=0; i<=nrows-1; i++) sum += tableta (3); It will sum the table values in the rows only. It will sum the table values in the columns only. It will not sum the table values because nrows is too small. It will not sum the table values because the columns are not...

  • Consider the following C++code snippet and what is the output of this program? # include<iostream> using...

    Consider the following C++code snippet and what is the output of this program? # include<iostream> using namespace std; void arraySome (int[), int, int); int main () const int arraysize = 10; int a[arraysize]-1,2,3,4,5, 6,7,8,9,10 cout << "The values in the array are:" << endl; arraySome (a, 0, arraySize) cout<< endl; system ("pause") return 0; void arraySome (int b[], int current, int size) if (current< size) arraySome (b, current+1, size); cout << b[current] <<""; a) Print the array values b) Double...

  • Consider the following code C++ like program: int i, j, arr[5]; //arr is an array starting...

    Consider the following code C++ like program: int i, j, arr[5]; //arr is an array starting at index 0 void exchange(int x, int y) { int temp:= x; x:= y; y:= temp; } main(){ for (j = 0; j < 5; j++) arr[j]:= j; i:= 1; exchange(i, arr[i+1]); output(i, arr[2]); //print i and arr[2] } What is the output of the code if both parameters in function swapping are passed by: a- value? b- reference? c- value-result?

  • What is output by the following program segment when function f3 is called twice? void f3()...

    What is output by the following program segment when function f3 is called twice? void f3() {static int x = 0; x++; cout << x << end l;}

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT