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

Given the following code, write a single FOR loop that displays the following pa

ID: 3555088 • Letter: G

Question

Given the following code, write a single FOR loop that displays the following pattern of numbers: 5, 6, 7, 8, 9, 10, 11, 12

#include <iostream>
using namespace std;

int main() {
int i = 0, j = 0;

// YOUR CODE GOES HERE

return 0;
}

Given the following code, write a WHILE or DO-WHILE loop that prompt the user for a value on [0, 10]. If the user enters a number on this interval, continue with the program. If the user enters a number that is not on the interval, informatively re-prompt until the user enters an appropriate number.

#include <iostream>
using namespace std;

int main() {
int i = 0, j = 0;

// YOUR CODE GOES HERE

return 0;
}

Explanation / Answer

//PART A
#include<iostream>
using namespace std;
int main()
{
int i=0,j=0;
for(i=0;i<7;i++)
cout<<i+5<<",";
cout<<i+5;
return 0;
}
/**************************************************/
//PART B
#include<iostream>
using namespace std;
int main()
{
int i=0,j=0;
while(1)
{cout<<"Enter a number in tha range [0,10] :";
cin>>i;
if(i>=0&&i<=10)
break;
else
cout<<"Please re-enter the appropriate number . "<<endl<<endl;
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote