InterviewSolution
Saved Bookmarks
| 1. |
Identify the possible error(s) in the following code fragment. Discuss the reason(s) of error(s) and correct the code:cin>>i>>j;while(i<j) cout<,i*j;i++; |
|
Answer» Correct code: cin>>i>>j; while(i<j) { cout<<i * j; i++; } Reasons of errors: (i) There is a use of ‘<,’ in cout statement instead of ‘<<’ which is not valid. (ii) while statement should be in curly braces otherwise it will not work properly. |
|