Prob. 1

In the code given below, write the output of the cout statements and provide justifications.

int main() {
int count, sum;
int count1, check;
count = 2;
sum = 0;
count1 = 0;
while (count < 100) {
check = 8 / count;
if (check == 10 || check == 5) {
count1 += 10;
sum += count1;
}
if (check == 2) {
count = 200;
} else {
count += 2;
}
}
cout << "The contents of the variable count is “ < The contents of the variable sum is“ << sum;
return 0;
}

Prob. 2

In the code given below, identify the compiler errors and state the reasons. Correct the errors and write the output of the program.

#include < iostream >
using namespace std;
int main() {
for (int i = 10; i >= 5; i--) {
int k = 10;
cout << k << "(" << i << ")" << endl;
k = k - 2;
cout << k << "(" << i << ")" << endl;
}
for (k = 10; k >= i; k--) {
int i = 10;
cout << i << endl;
i = i - 2;
cout << ::i << endl;
}
return 0;
}

Prob. 3

In the code given below, there are two compiler errors and two run-time errors on the lines with comments. Identify the errors and rectify the code.

#include < iostream > using namespace std;

int main() {
int nData1 = 9, nData2 = 5;
int * pData1, * pData2;
pData1 = & nData1;
pData2 = & nData2; * pData2 = pData1 + pData2; // Perform addition of nData1 and nData2 and store the result in nData2.

cout << "The address of the variable nData1 is " << nData1 << endl; // Display address of nData1
float fData = 10.0;
float *pfData;

&pfData = * fData; // Store the addresss of fData in the pointer pfData. cout<<"The data stored in the variable fData "<
return 0;
}

Prob. 4

  • Complete the template code to match the execution of the Prob.4 executable provided.
  • Read the comments in the template code and add your code below the comments.
  • You are not allowed to define any new variables or modify the template code.
#include "EE4075.h"

int main()
{
int nNumber;

do {
cout << "Enter an integer number between 20 and 100: ";
cin >> nNumber;

if (nNumber > 100)
{
cout << "The number entered is greater than 100" << endl;
cout << "I am skipping the rest of the computation in the do-while loop" << endl;

//Write an appropriate command to skip executing the rest of the code in the do-while loop. Points: 1.0

}

//Write a single if condition to check whether the number is greater than or equal to 20 and less than or equal to 100. Points: 2.0


if (nNumber < 20)
{
cout << "The entered number if less than 20" << endl;
cout << "Exiting the do-while loop and the application" << endl;
//Write an appropriate command to break prematurely out of the do-while loop. Points: 1.0

}
} while (true);


KeepWindowOpen();
return 0;
}
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.