Question

How to trace a c++ program by hand #include<iostream> using namespace std;    class Test {...

How to trace a c++ program by hand

#include<iostream>

using namespace std;

  

class Test {

    int value;

public:

    Test(int v);

};

  

Test::Test(int v) {

    value = v;

}

  

int main() {

    Test t[100];

    return 0;

}

_______________

#include <iostream>

using namespace std;

int main()

{

int i,j;


for (i=1; i<=3; i++)

{

for(j=1; j<=i; j++ )

{

cout<<"*";

}

cout << "\n";

  }

return 0;

}

Homework Answers

Answer #1
Answer1:
Always we should start with main:
int main we are create array of references for class Test
so here we are creating the 100 objects but it will throw an error
as we are creating objets with default constructor but in class Test 
we dont have default constructor


Answer 2:
Here we have 2 loops
i-1 and i<=3
    j=1 and j<=i
so 1st i=1
*
i=2
*
* *
i=3
*
* *
* * *

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME

Know the answer?
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
Similar Questions
whats the output of the following program? #include <iostream> using namespace std; int main () {...
whats the output of the following program? #include <iostream> using namespace std; int main () { int fistNum = 28; int secondNum = 25; cout << firstNum << " " << secondNum << end1; cout << (firstNum = 38-7) << end1; cout << (firstNum <= 75) << end1; cout << (firstNum > secondNum + 10) << end1; cout << (firstNum >= 3 * secondNum - 100) << end1; cout << (secondNum - 1 == 2 * firstNum) << end1; cout...
This code it's not working, fix it for me please #include <iostream> using namespace std; class...
This code it's not working, fix it for me please #include <iostream> using namespace std; class People {    string name;    double height; public:    void setName(string name)    {        this->name = name;    }    void setHeight(double height)    {        this->height = height;    }    double getHeight() {        return height;    }    string getName()    {        return name;    } }; int main() {    const int size...
Analyze the following program and write down the output. # include <iostream> using namespace std;    void...
Analyze the following program and write down the output. # include <iostream> using namespace std;    void modifyArray( int [ ], int );    void modifyElement ( int );      int main( ) {   const int arraySize = 8;   int a[arraySize] = { 2, -2, 10, -3, -1 ,0, 10, -5 };      modifyArray ( a, arraySize);      for ( int i =0; i < arraySize; i++)               cout << a[i] << ‘  ’;         modifyElement ( a[4] );          for ( int i =0; i <...
Rewrite the following program using switch statements. //Set 7.1 #include <iostream> #include <iomanip> using namespace std;...
Rewrite the following program using switch statements. //Set 7.1 #include <iostream> #include <iomanip> using namespace std; int main() {        int x;        cout << "Selection option " << endl;        cin >> x;        if (x == 1)               cout << "You select option 1" << endl;        else if (x >= 2 || x <= 4)               cout << "You select options 2 or 3 or 4" << endl;               else if (x == 10)               cout << "You select option 10" << endl;               else...
/* Displaying process segment addresses */ #include <iostream> extern int etext, edata, end; using namespace std;...
/* Displaying process segment addresses */ #include <iostream> extern int etext, edata, end; using namespace std; int main( ){ cout << "Adr etext: " << hex << int(&etext) << "\t "; cout << "Adr edata: " << hex << int(&edata) << "\t "; cout << "Adr end: " << hex << int(&end ) << "\n"; return 0; } please modify this above code and execute to get the output.
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std;...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std; int fib(int n) { int temp; if (n <= 0)    return 0; else if (n <= 2)    return 1; else {    temp = fib(n – 1);    return temp + fib(n-2); } } int main() {    int num;    cout << "Which fibonacci number? ";    cin >> num;    cout << fib(num) << endl;    return 0; } You...
#include <iostream> #include <string> using namespace std; int pal(int n, int temp) {    // Using...
#include <iostream> #include <string> using namespace std; int pal(int n, int temp) {    // Using division of 10 trick    if(n == 0)        return temp;    // Build the number backs.    temp = (temp * 10) + (n % 10);    // Then advance through the number.    return pal(n / 10, temp); } int main() {    system("clear");    int num;        // Ask the user for an input.        cout << "\nEnter...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std;...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std; int theArray[] = { 5, 11, -29, 45, 9, -1}; void sumPos(int ary[], int len, int &sum) {    sum = 0;    for (int i = 0; i < len; i++)            if (ary[i] > 0)                sum = sum + ary[i]; } int main() {    int total;    sumPos(theArray, 6, total);    for (int k=0; k < 6; k++)      cout...
C ++ #include <fstream> #include <iostream> using namespace std; int main() { float bmi; ifstream inFile;...
C ++ #include <fstream> #include <iostream> using namespace std; int main() { float bmi; ifstream inFile; inFile.open("bmi.txt"); while (!inFile.eof()) { inFile >> bmi; if( bmi < 18.5) { cout << bmi << " is underweight " ; } else if( bmi >= 18.5 && bmi <= 24.9) { cout << bmi << " is in normal range " ; } else if( bmi >= 25.0 && bmi <= 29.9) { cout << bmi << " is overweight " ; }...
What will be the output of the following code? #include <iostream> using namespace std; int main()...
What will be the output of the following code? #include <iostream> using namespace std; int main() {    char *s = "hello";    char *p = s;    cout << *(p+3) << " " << s[1] << endl; }