Answer:
Option d is the correct answer for the above question.
Explanation:
- The first loop of the program has a second loop and then the statement. In this scenario, the second loop executes for the value of the first loop and the statement executes for the value of the second loop.
- The first loop executes 4 times, Then the second loop or inner loop executes n times for the n iteration of the first loop, for example, 1 time for the first iteration of the first loop, 2 times for the second iteration of the first loop and so on.
- Then the inner loop executes (1+2+3+4) iteration which gives the result 10 iterations.
- The sum initial value is 0 and the "sum++", increase the value of the sum by 1.
- So the value of the sum becomes 10 after completing 10 iterations of the inner for loop.
- Hence the 10 will be the output. So the Option d is the correct answer while the other is not.
Answer:
The missing code to this question is g.
Explanation:
In this question firstly import packages. Then declaration of the class Test that inherits the JApplet. In this class, we declare the default constructor. In this constructor, we call the add function. Then we declare another class that is SquarePanel. This class inherits JPanel. In this class, we define a method that is paintComponent(). In this method, we define an integer variable. In this method, we perform calculations and pass it to another function that is displaySquares(). In this function, we pass the value as the arguments. So in question the missing code or argument is g.
Answer:
See Explanation
Explanation:
The question is incomplete as there is no link pointing to the houseType struct of chapter 1.
So, I've answered the question from scratch
See attachment for explanation where I used comments to explain each line.
The program is as follows:
#include <iostream>
using namespace std;
struct houseType{
int firstHouse, secondHouse;
};
int main()
{
houseType hT;
cout << "Enter the price of both house: ";
cin>> hT.firstHouse;
cin>> hT.secondHouse;
if(hT.firstHouse == hT.secondHouse){ cout<<"true"; }
else{ cout<<"false"; }
return 0;
}