Computer Applications
What is a compound statement? Give an example.
Input in Java
63 Likes
Answer
Two or more statements can be grouped together by enclosing them between opening and closing curly braces. Such a group of statements is called a compound statement.
if (a < b) {
/*
* All statements within this set of braces
* form the compound statement
*/
System.out.println("a is less than b");
a = 10;
b = 20;
System.out.println("The value of a is " + a);
System.out.println("The value of b is " + b);
}
Answered By
44 Likes
Related Questions
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
Write the syntax of 'if' statement.
Define the following:
(a) Normal flow of control
(b) Conditional flow of control
Write down the syntax of the following with reference to Java Programming:
(a) to accept an integer value using main( )
(b) to accept a fractional number using main( )