Computer Applications
Write the syntax of 'if' statement.
Input in Java
30 Likes
Answer
The syntax of 'if' statement is as follows:
if(condition )
Statement
OR
if(condition)
{
Statement 1
Statement 2
:
:
Statement n
}
Answered By
21 Likes
Related Questions
class Simplify { public static void main(String args[]) { int a,b,c,d; a=10,b=5,c=1; c=2a+2b; d=(a+b)2; p=c/d; System.out.println(c , d , p); } }
It is possible that the user may not be able to write an error-free program at one go. Due to this reason, debugging is significant. Debugging is used to eliminate errors from a program. Some of the examples describing the errors are given below:
(a) A number divided by zero.
(b) The user has applied multiplication sign, instead of division sign.
(c) Sum of p and q is to be divided by their difference using the statement p+q/p-q.
(d) While writing a Java statement, the user forgot to terminate the statement using semicolon.
Based on the above case, answer the following questions:
What is the type of error in (a)?
- Syntax Error
- Logical error
- Runtime error
- Execution error
What is the type of error in (b)?
- Logical error
- Syntax error
- Compiler error
- Execution error
What is the type of error in (c)?
- Logical error
- Syntax error
- Runtime error
- Execution error
What is the type of error in (d)?
- Syntax error
- Logical error
- Runtime error
- Compilation error
What is a compound statement? Give an example.
Define the following:
(a) Normal flow of control
(b) Conditional flow of control