26 Jan 2017

What is control statements ..??

First of all the main question arises about the statements  that is  "What is a statements in a program ".

The answer is "It is smallest  unit of a program that is a complete instruction in itself. " Statements of java generally contain  expressions a end with a semi-colon (;). The two most commonly used statements in any programming language are as follows:


Sequential statements : These are the statements which are executed one by one .

Control statements : These are the statements that are executed randomly and repeatedly .
These are followed by java also.

Now lets assume an example :

System.out.println("Hello Jarvis");
a=b+c;
System.out.println("a");

So what you think , what type of statement it is

I tell  you that  is the example of Sequential statements as you can see that the execution of statements are in sequence .

What is control statements?

Control statements are the statements which alter the flow of execution and provide better control to the programmer on the flow of execution . They are useful to write better and complex programs.


These are the following control statements are available in java:


  1. if-else statement
  2. do-while loop
  3. while loop
  4. for loop 
  5. for-each loop 
  6. switch statement 
  7. break statement 
  8. continue statement
  9. return statement 





















No comments:

Post a Comment