Point out the errors.

Q18. Point out the errors in the following program:

int main()

{

            cout<<”Enter variable”;

            cin>>var

            sqrs=var*var

            cout<<”The square is”<<sqrs;

Ans.

  1. The header file iostream.h has not been included.
  2. The variables var and sqrs have not been declared before using them.
  3. The statements cin>>var and sqrs=var*var have not been terminated by;
  4. The return statement of main() is missing.
  5. The closing bracket ‘}’ is missing.

Leave a Reply

Your email address will not be published. Required fields are marked *