can someone please explain why 333 22 1 is printed on the screen? i have an idea as to why but it would help if an expert could explain why.
int main()
{
for (int i = 3; i > 0; i--) {
for (int j = 1; j <= i; j++)
{
cout <<
i;
}
cout << endl;
}
system("pause");
}
for (int i = 3; i > 0; i--) {
for (int j = 1; j <= i; j++) {
cout << i;
}
cout << endl;
}
i = 3
j = 1
prints i -> prints 3
j = 2
prints i -> prints 3
j = 3
prints i -> prints 3
then prints a new line
so, it prints 333 when i=3
i = 2
j = 1
prints i -> prints 2
j = 2
prints i -> prints 2
then prints a new line
so, it prints 2 when i=2
i = 1
j = 1
prints i -> prints 1
then prints a new line
so, it prints 1 when i=1
then loop exists because i = 0 and (i > 0) is false
Output:
---------
333
22
1
can someone please explain why 333 22 1 is printed on the screen? i have an...
c++) explain your answer. What will be printed on the screen? explain your answer. int main() { int i = 3, j = 4; int x = 0; try { if(i < j) throw “Oops!”; } catch(int i) { x = 1; } catch(double d) { x = 3; } catch(...) { x = 4; } cout << "x = " << x << endl; return 0; }
Can someone explain how this C++ program runs? A line by line explanation/commentation would be great, as well as the purpose of the program and functions/classes involved. #include <iostream> #include <vector> using namespace std; // template function vector<int> removeEvenIndexedVals(vector<int> vec); // main int main() { static const int arr[] = { 2,5,7,9,1,3,6 }; vector<int> vec(arr, arr + sizeof(arr) / sizeof(arr[0])); // call function vec = removeEvenIndexedVals(vec); // print cout << "Displaying the Vector Elements:"...
Can someone help run this and fix a small error I have when I run this. I get a constant variable error on line 62. I have a constant variable though and I'm sure what to change. I use Visual Basic 2017 as well for any of those wondering. Please help and thanks in advance #include <ctime> #include <iostream> #include <random> #include <string> using namespace std; int main() { const int paper = 0, rock = 1, scissors = 2;...
C++: what is i and j. IMPORTANT I know it's 3 and 3 but can someone please explain how we can get to that conclusion by just reading the code, can it be explained to me because when i try to do it I get a different answer for i and j I got 1 and 4. #include <iostream> using namespace std; int main() { int i = 1; int j = 0; if (i++ == 1) { j =...
Id: 40100885
in c++
output text please
thanks!
what is the output values printed by the following code? You need to explain step by step how each printed value is calculated. #include <iostream> using namespace std; int m = 0; void SampleMethod (int); int SampleMethod(); void increase(); int main() { int j = 9; SampleMethod(j); cout << j<<endl; return 0; w Y == void SampleMethod(int i) { if (j%2 1) cout << SampleMethod() <<endl; else cout << j << "...
I've created a functioning program but I can't figure out how to implement class structure into it. I'm currently studying classes and I'm wondering if you could help me recreate my program with classes so I can have a better understanding of how classes work. Thank you. #pragma once #include <iostream> using namespace std; bool DeclareResults(char ch, char gameboard[][3]); bool FilledBoard(char gameboard[][3]); void printGameBoard(char gameboard[][3]); #include "fnt.h"; #include <iostream> using namespace std; int main() { //declare...
Can I get help with adding the following to this code please? 1. When buying multiple tickets, if one of the seats selected is already taken, give a message like "Sorry, one or more of the seats selected is already taken." and prompt the user to select the seats all over. (Or if possible to make it suggest a location where the seats are together that the user can select instead) 2. Print the total cost after all of the...
Hey, so i am trying to have my program read a text file using a structure but i also want to be able to modify the results(I kinda have this part but it could be better). I cant seem to get it to read the file(all the values come up as 0 and i'm not sure why because in my other program where it wrote to the txt file the values are on the txt file) i copied and pasted...
Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...
Can someone explain the process of this Display a text file program and show the supposed output of the program? I tried it with my text file and all it does is printing out the same line of words for 24 times. Can you also explain what the [COL_WIDTH + 1 ] and the c = input_line [0] ; is doing? Please show me what this program is doing. Thanks. Here below is the actual program. #include #include using namespace...