(d) Name the type of error (syntax, runtime or logical error) in each case given below:
(i) Math.sqrt (36-45)
(ii) int a;b;c;
Answers
Answered by
46
Ans. (i) Runtime error
Math.sqrt(36-45) = Math.sqrt(-9) which cannot be computed as square root of a negative number is not defined. Therefor, a runtime error will be thrown.
(ii) Syntax error
Multiple variables can be defined in one of the following ways
int a, b, c;
int a; int b; int c;
T4Talent:
Tysm❤
Answered by
4
The type of error (syntax, runtime, or logical error) in each case is given below:
- Math. sqrt (36-45)- Run time error as when we subtract (36-45), we get the result of -9, and the function given is 'Math. sqrt' which performs the square root of the expression given in the brackets. As we know the square root of any negative number does not have an existence, as a result of which there will be a run time error.
- int a;b;c; - Syntax error as we know that for declaring any variable in any program we have to first give the data type then the variable and then the semicolon. If we want to declare three variables in one data type, then we must use a comma after one variable and a semicolon for the last variable. It is therefore a syntax error.
Similar questions