CBSE Class 11 Informatics Practices Control Structures

Read and download CBSE Class 11 Informatics Practices Control Structures in NCERT book for Class 11 Informatics Practices. You can download latest NCERT eBooks chapter wise in PDF format free from Studiestoday.com. This Informatics Practices textbook for Class 11 is designed by NCERT and is very useful for students. Please also refer to the NCERT solutions for Class 11 Informatics Practices to understand the answers of the exercise questions given at the end of this chapter

NCERT Book for Class 11 Informatics Practices Control Structures

Class 11 Informatics Practices students should refer to the following NCERT Book Control Structures in Class 11. This NCERT Book for Class 11 Informatics Practices will be very useful for exams and help you to score good marks

Control Structures NCERT Book Class 11

 

Control Structures

Selection Statements

Observe the form execution given in Figure 6.1 carefully and try to analyze the problem. Figure 6.1 Sample Run of The Vote Eligibility Checker Application Observing the sample run of the above application, it is clear that we have designed an application where we are accepting the age from the user and we want to validate whether the person is eligible to vote or not. We are accepting the age of the user in a text field and testing whether the age entered by the user is greater than 18 or not. If the age is greater than 18 then the message "You are eligible to VOTE" is displayed.

In suchsituations when we have to take action on the basis of outcome of a condition, we need to use a Selection statement. Design the form and set the properties of the components so that the form looks exactly like the one displayed in figure 6.1. Let us now try to write the code for the "Check Eligibility To Vote" button as given in Figure 6.2. The code for the STOP button is the same as learnt in previous chapters.

retrieves the value entered by the user in the text field using getText().This value by default is treated as a string and not as a number so it needs to be converted to an integer type and this is achieved using the parseInt() method. if (Integer.parseInt(jTextField1.getText()) >=18)

check whether the value retrieved from the text field is greater than or equal to 18 or not. The if statement is used to check the condition and if the condition evaluates to true then we specify what action is to be taken if (Integer.parseInt(jTextField1.getText()) >=18)

JOptionPane.showMessageDialog(null, "You are eligible to VOTE")

This if statement is used to check whether the value retrieved from the text field is greater than or equal to 18 or not and if it is then it displays the message "You are eligible to VOTE" using the showMessageDialog() method. Can you guess what will happen if the condition evaluates to false in the above application? Understanding the if statement completely will help us answer this question.

The if statement allows selection (decision making) depending upon the outcome of a condition. If the condition evaluates to true then the statement immediately following if will be executed and otherwise if the condition evaluates to false then the statements following the else clause will be executed. Thus, if statement is a selection construct as the execution of statements is based on a test condition. The selection statements are also called conditional statements or decision control statements.

The syntax of if statement is as shown below:

Syntax:

if (conditional expression)

{

Statement Block;

}

else

{

Statement Block;

}

There are certain points worth remembering about the if statement as outlined below:

The conditional expression is always enclosed in parenthesis. The conditional expression may be a simple expression or a compound expression.

Each statement block may have a single or multiple statements to be executed. In case there is a single statement to be executed then it is not mandatory to enclose it in curly braces ({}) but if there are multiple statements then they must be enclosed in curly braces ({})

The else clause is optional and needs to be included only when some action is to be taken if the test condition evaluates to false.

After familiarizing with the if statement, can you now understand what will happen in the above application if the Age entered by the user is less than 18? Well in that case, the user will not get any message because we have not included the else clause in our code above. So, let us re-write the program to take care of both the cases i.e. Age>= 18 as well as Age <18. The modified code for this application is given in Figure 6.3.

 

Please refer to the link below - CBSE Class 11 Informatics Practices Control Structures

NCERT Book Class 11 Informatics Practices Control Structures

The above NCERT Books for Class 11 Informatics Practices Control Structures have been published by NCERT for latest academic session. The textbook by NCERT for Control Structures Informatics Practices Class 11 is being used by various schools and almost all education boards in India. Teachers have always recommended students to refer to Control Structures NCERT etextbooks as the exams for Class 11 Informatics Practices are always asked as per the syllabus defined in these ebooks. These Class 11 Control Structures book for Informatics Practices also includes collection of question. Along with Informatics Practices Class 11 NCERT Book in Pdf for Control Structures we have provided all NCERT Books in English Medium for Class 11 which will be really helpful for students who have opted for english language as a medium. Class 11 students will need their books in English so we have provided them here for all subjects in Class 11.

Where can I download latest NCERT Book for Class 11 Informatics Practices Control Structures

You can download the NCERT Book for Class 11 Informatics Practices Control Structures for latest session from StudiesToday.com

Can I download the NCERT Books of Class 11 Informatics Practices Control Structures in Pdf

Yes, you can click on the link above and download chapter wise NCERT Books in PDFs for Class 11 for Informatics Practices Control Structures

Are the Class 11 Informatics Practices Control Structures NCERT Book available for the latest session

Yes, the NCERT Book issued for Class 11 Informatics Practices Control Structures have been made available here for latest academic session

How can I download the Class 11 Informatics Practices Control Structures NCERT Book

You can easily access the link above and download the Class 11 NCERT Books Informatics Practices Control Structures for each chapter