Sarthaks Test
0 votes
78 views
in Computer by (68.8k points)

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++;

1 Answer

+1 vote
by (63.6k points)
selected by
 
Best 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.

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...