Code Error Finding – CSKC
Sign In

Search

Solved Problem #CPP#5368    siteicon   siteicon  

Problem Statement - Code Error Finding

Rewrite the following program after removing possible compiler errors. Mark each correction by underlining it. Assume that relevant header files are included.

int main()
{
  const int d 5;
  number = 15;
  for(int i=1; i<=5; i++, number-=3)
    if(number%d==0) cout<<number/d<<" ";
    else cout<<number+d<<" ";
}

Solution

TC++ #5368

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

int main() {
const int d=5;
Here = is required between d and 5

int number = 15;
Here int is required for variable type.

for(int i=1; i<=5; i++, number-=3)
if(number%d==0) cout<<number/d<<” “;
else cout<<number+d<<” “;

return 0;
Since main is returning int so this statement should preferably be given. Some compilers may report this as an error.

}

 


Share

Created: 9-Dec-2018 23:04 | Updated: 22-Mar-2026 20:22|