4.1.1. The if statement, Chapter - 4, Control Structures, HSSC-II (12th Class) Computer Science Key Point Notes

4.1.1. The if statement, Chapter - 4, Control Structures, HSSC-II (12th Class) Computer Science Key Point Notes

12th Class (HSSC-II) Computer SLO Based Key Point Notes

(National Book Foundation - As Federal Textbook Board, Islamabad 
Based on National Curriculum Pakistan 2023-2024 and Onward prescribed by Federal Board of Intermediate and Secondary Education, Islamabad, and All Pakistan Boards) 

{Contact WhatsApp 03339719149 for Class-XII Computer Science Complete SLO-Based Key Points notes in pdf format as well as in PowerPoint Presentation for preparing/delivering the Lectures}

************************************

👉👉👉 Computer Science 12th Class Notes (Main Page)

************************************

Unit 4: Control Structures

4-1-1 The if statement

The if statement is a decision-making statement that is used to execute or skip a statement by checking a condition.

General Syntax:

        if (condition)
        {
        statements;
        }


Flow chart




Explanation:

  • The condition is evaluated.
  • If the condition is true, the block of statement within the braces is executed.
  • If the condition is false, the block of statements is skipped and control is transferred to the next statement after the closing brace.
  • If there is a single statement to be executed then braces are not required.

Example

Write a program that inputs marks and displays “Congratulations, You have passed” if the marks are 40 or more.

#include<iostream.h>
#include<conio.h>
void main()
{
            clrscr();
            int marks;
            cout<<“Please enter your Marks: “;
            cin>>marks;
            if (marks >= 40)
            {
            cout<<“Congratulations, You have passed”;
            }
            getch();
}



Limitation of if statement

if the statement is the simplest selection structure which executes the statement or set of statements if the condition is true, but if the condition is false then nothing will happen. 


************************************
👉👉👉 Computer Science 12th Class Notes (Main Page)

************************************


************************************
Shortcut Links For:

1.  5th Class All Subjects Notes

2.  8th Class All Subjects Notes

3.  Easy English Grammar Notes



1. Website for School and College Level Physics   
2. Website for School and College Level Mathematics  
3. Website for Single National Curriculum Pakistan - All Subjects Notes 

© 2023 & onwards Academic Skills and Knowledge (ASK  

Note:  Write me in the comments box below for any query and also Share this information with your class-fellows and friends.

Post a Comment

0 Comments

cwebp -q 80 image.png -o image.webp