Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have 3 questions I don\'t understand them so I can\'t find the answer please h

ID: 3627520 • Letter: I

Question

I have 3 questions I don't understand them so I can't find the answer please help.

1. What is the output from the following C++ code fragment?

int count = 1;
int y = 100;
while(count < 100)
{
y = y - 1;
count++;
}
cout << "y = " << y << " and count = " << count << end;

2. What is the output from the following C++ code fragment?

int num = 1;
while(num < 10)
{
cout << num << " ";
num += 2;
}
cout << end;

3. What is the output from the following C++ code fragment if the following values are the inputs to cin?

38 35 71 14 -10

int sum, num;
cin >> sum;
for(int j = 1; j <= 3; j++)
{
cin >> num;
sum += num;
}
cout << "Sum = " << sum << endl;

Explanation / Answer

1. What is the output from the following C++ code fragment?

int count = 1;
int y = 100;
while(count < 100)
{
y = y - 1;
count++;
}
cout << "y = " << y << " and count = " << count << end;

y = 1 and count = 100


2. What is the output from the following C++ code fragment?

int num = 1;
while(num < 10)
{
cout << num << " ";
num += 2;
}
cout << end;

1 3 5 7 9       // it wil just print odd numbers


3. What is the output from the following C++ code fragment if the following values are the inputs to cin?

38 35 71 14 -10

int sum, num;
cin >> sum;
for(int j = 1; j <= 3; j++)
{
cin >> num;
sum += num;
}
cout << "Sum = " << sum << endl;

sum = 158 // this is nothing but sum of first 4 numbers in input.