8 The code in Figure 824 should display the pattern of amper

8. The code in Figure 8-24 should display the pattern of ampersands shown in the figure, SWAT THE BUGS but it is not working correctly Debug the code. but it is not working correctly. Debug the code.

Solution

//In the first loop condition change row<4 to row<=4

//The second error is in the second loop condition change col<5 to col<=row.

#include <iostream>
using namespace std;
int main()
{
   for(int row=1;row<=4;row+=1)
   {
       for(int col=1;col<=row;col+=1)
           cout<<\'&\';
       cout<<endl;
   }

   return 0;
}

 8. The code in Figure 8-24 should display the pattern of ampersands shown in the figure, SWAT THE BUGS but it is not working correctly Debug the code. but it i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site