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;
}
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
Get Answers For Free
Most questions answered within 1 hours.