int main ()
{
int gamma;
int delta;
gamma = 5;
delta = 10;
DoThis(gamma, delta);
cout << “gamma is “ << gamma << “delta is “ << delta << endl;
}
void DoThis(int alpha, int beta)
{
alpha = 2;
beta = 3;
cout << "alpha is " << alpha << "beta is " << beta << endl;
}
What is the output from the above program?
#include <iostream> using namespace std; void DoThis(int alpha, int beta); int main () { int gamma; int delta; gamma = 5; delta = 10; DoThis(gamma, delta); cout << "gamma is " << gamma << "delta is " << delta << endl; } void DoThis(int alpha, int beta) { alpha = 2; beta = 3; cout << "alpha is " << alpha << "beta is " << beta << endl; }
C++ question #include <iostream> using namespace std; void printReverse(int); int main() { int number = 12345; cout << "Original : " << number << endl; cout << "Reversed : "; printReverse(number); } void printReverse(int x) { if (x == 0) return; cout << x % 10; printReverse(x /= 10); } Modify the above recursive program to output the number in the same order. Note that the program still should break up the number and then output it in the...
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...
What is the output of the following program? int main(void) { int x, y, z; x = 5; y= test(x); z= x + y; cout<< setw(4)<<x <<” + “<<setw(4)<<y<<”=” << setw(4)<<z<<endl; return 0; } int test (int x) { int w; w = x + 10; return (w); }
Give the output for the following code assume int globalvar 10: above the function prototypes void foo(int&); void bar(int); int main() { int globalVar = 5; foo(globalVar); cout << globalVar << endl; bar(globalVar); cout << globalVar << endl; return 0; } void foo(int& x) { x = globalVar + x; cout << globalVar << endl; return; void bar(int x) { globalVar + x; cout << globalVar << endl; X = return;
in c++ #include <iostream> using namespace std; int main() int beta[7] = 3, 5); for (int i = 2; i < 7; i++) beta[i] = 3 * i + 2; beta[i - 1] = beta[i - 1] + beta[i]; beta[i - 2) = betali - 2] + beta (i - 1]; for (int i = 0; i < 7; i++) cout << beta[i] << " "; cout << endl; return 0;
#include using namespace std; void test(); int x = 0; int main(){ cout << x << endl; test(); cout << x << endl; } void test(){ int x = 100; cout << x << endl; for(int x = 0; x < 5; x++){ cout << x << endl; } } how many separate variables named ‘x’ are created?
4. Consider the following (almost) complete program: 4includeciostream> using namespace std: la)prototypes here. int main () const int size 6 int alsize] 15, 2, 3, 1, 13, 8): int p pma+1 show (a, size) mystery (a, size); show (a, aize) cout<<a [2]+a(51<<endl; cout<<(a+2)-3<<endl: cout<<tp+ a<<endl; cout<<at5<cendl void show (int all, int n) 17 (b) define show void mystery (int all, int n) int temp Eor (int i-0 i<n/2 i++) temp aij alil-aln-i-117 a [n-i-11 temp a) Write prototypes for the...
1. What is wrong with the following C++ program? #include <iostream> int main() { a = 4; b = 6; cout << a << "+" << b << "=" << a+b; return 0; 2. What is wrong with the following C++ program? What was its intended output? #include <iostream> using namespace std; int main() { cout << "What is larger? e pi or pi e?" << endl; double ans1 = exp(pi); double ans2 = pi exp(1.); cout << "epi is...
Consider the following C++ program: #include <iostream> #include <cstdlib> using namespace std; int main int n =0; int i = 0; cout << "Please enter a strictly positive number:"; cin >> n if (n <= 0) exit(EXIT_FAILURE) while (n > 1) n-n/2; i << endl; cout"Output:" return 0; Answer the following questions: What is the output of the program for each of the following values of n: -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9? What does...
#include <iostream> #include <cmath> using namespace std; int main() { int x; int y; int z; int r1; int r2; cin >> x; cin >> y; cin >> z; r1 = 4* pow(x,3)-5*pow(y,2)+3*z; r2 = r1+7*pow(x,3)-2*pow(y,2)+11*z; cout << "r1="; cout << 4* pow(x,3)-5*pow(y,2)+3*z; cout << endl; cout << "r2="; cout << r1+7*pow(x,3)-2*pow(y,2)+11*z; cout << endl; cout << "r3="; cout << r2-9*pow(x,3)+22*pow(y,2)-6*z; cout << endl; return 0; } 1-115 Your output r2-395 13-186 5:Compare output Output differs. See highlights below. -163...