Menu

[Solved] Output Following Code Assume Necessary Headers Provided Void Deposit Int B Int Amount B Am Q37227617

What will be theoutput of the following code? Assume all necessary headers areprovided.

void deposit(int &b, int amount)
{
b += amount;
}

int main()
{
int balance = 0;
deposit(balance, 10);
cout << ‘$’ << balance;

return 0;
}Flagthis Question
10 pts

What will be theoutput of the following code? Assume all necessary headers areprovided.

void withdraw(int b, int amount)
{
b -= amount;
}

int main()
{
int balance = 100;
withdraw(balance, 50);
cout << ‘$’ << balance;

return 0;
}Flagthis Question
10 pts

What will be theoutput of the following code? Assume all necessary headers areprovided.

bool isGreater(int x, int y)
{
return x>y;
}

int main()
{
int num1 = 5, num2 = 10;
if(isGreater(num1, num2)){
cout << “*****”;
} else {
cout << “—–“;
}

return 0;
}Flagthis Question
10 pts

What will be theoutput of the following code? Assume all necessary headers areprovided.

void printNum(int x)
{
cout << x << ” “;
}

int main()
{
for(int i = 1; i <= 5; ++i)
{
printNum(i);
}

return 0;
}Flagthis Question
10 pts

What will be theoutput of the following code? Assume all necessary headers areprovided.

void square(int &x)
{
x *= x;
}

int main()
{
int num1 = 5;
square(num1);
cout << num1;

return 0;
}Flagthis Question
10 pts

What will be theoutput of the following code? Assume all necessary headers areprovided.

bool isEven(int x)
{
if(x % 2 == 0){
return true;
} else {
return false;
}
}

int main()
{
for(int i = 1; i <= 5; ++i)
{
if(isEven(i)){
cout << i << ” “;
}
}

return 0;
}Flagthis Question
10 pts

What will be theoutput of the following code?

#include <iostream>
#include <iomanip>

using namespace std;

void printMoney(float x)
{
cout << ‘$’ << fixed << showpoint << setprecision(2) << x;
}

int main()
{
float num1 = 25;
printMoney(num1);

return 0;
}Flagthis Question
10 pts

What will be theoutput of the following code? Assume all necessary headers areprovided.

void deposit(int &b, int amount)
{
b += amount;
}

int main()
{
int balance = 0;
deposit(balance, 10);
if(balance > 0)
{
cout << “Deposit Successful”;
} else {
cout << “Deposit Unsuccessful”;
}

return 0;
}Deposit SuccessfulDeposit Unsuccessful*This code would not compile*Flagthis Question10 pts

What will be theoutput of the following code? Assume all necessary headers areprovided.

void cube(int &x)
{
x = x*x*x;
}

int main()
{
int num1 = 2;
cout << num1 << ” cubed is “;
cube(num1);
cout << num1;

return 0;
}2cubed is 22cubed is 8*This code would not compile*

Expert Answer


Answer to What will be the output of the following code? Assume all necessary headers are provided.void deposit(int &b, int amount… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *