jagomart
digital resources
picture1_Chapter 10 Control Statements1


 155x       Filetype PDF       File size 0.99 MB       Source: keerthicomputerstudymaterials.files.wordpress.com


File: Chapter 10 Control Statements1
chapter10 control statements i puc mdrpuc hassan chapter 10 control statements introduction control statements are statements that alter the sequence of flow of instructions any single input statement assignment and ...

icon picture PDF Filetype PDF | Posted on 06 Feb 2023 | 2 years ago
Partial capture of text on file.
           Chapter10-Control Statements                                             I PUC,MDRPUC, Hassan
           Chapter-10
                                        CONTROL STATEMENTS
            Introduction
              Control statements are statements that alter the sequence of flow of instructions.
              Any single input statement, assignment and output statement is simple statement.
              A group of statement that are separated by semicolon and enclosed within curled braces { and } is
               called a block or compound statement.
              The order in which statements are executed in a program is called flow of control.
            Types of control statements:
              C++ supports two basic control statements.
                   o Selection statements
                   o Iteration statements
            Selection Statements:
              This statement allows us to select a statement or set of statements for execution based on some
               condition.
              It is also known as conditional statement.
              This structure helps the programmer to take appropriate decision.
              The different selection statements, viz.
                   o if statement
                   o if–elsestatement
                   o Nested–ifstatement
                   o switch statement
            ifstatement:
              This is the simplest form of if statement.
              This statement is also called as one-way branching.
              This statement is used to decide whether a statement or set of statements should be executed or
               not.
              The decision is based on a condition which can be evaluated to TRUE or FALSE.
              The general form of simple – if statement is:
                   if (Test Condition)      // This Condition is true
           1 | P a g e
          Chapter10-Control Statements                                   I PUC,MDRPUC, Hassan
                       Statement 1;
                Statement 2;
            Here, the test condition is tested which results in either a TRUE or
             FALSE value. If the result of the test condition is TRUE then the
             Statement 1 is executed. Otherwise, Statement 2 is executed.
          Ex:   if( amount > = 5000 )
                       discount = amount * (10/100);
                net-amount = amount – discount;
          Practical Program 5: Write a C++ program to find the largest, smallest
          and second largest of three numbers using simple if statement.
          #include
          #include
          void main( )
          {
                int a, b, c;
                int largest, smallest, seclargest;
                clrscr( );
                cout<<”Enter the three numbers”<>a>>b>>c;
                largest = a;                            //Assume first number as largest
                if(b>largest)
                       largest = b;
                if(c>largest)
                       largest = c;
                smallest = a;                           //Assume first number as smallest
                if(b
            #include
            void main( )
            {
                    float TAmount, discount, FAmount ;
                    clrscr( );
                    cout<<”Enter the Total Amount”<>TAmount;
                    discount = 0;                                           //Calculate Discount
                    if(TAmount>1000)
                            Discount = (8/100) *  TAmount;
                    FAmount = TAmount–Discount                              //Calculate Final Amount
                    cout<<”Toatal Amount = “<
          #include
          void main( )
          {
                int year ;
                clrscr( );
                cout<<”Enter the Year in the form YYYY”<>year;
                if(year%4 ==0 && year%100!=0 || year%400 ==0)
                       cout<
          #include
          void main( )
          {
                char ch ;
                clrscr( );
                cout<<”Enter the Character”<>ch;
                if(ch>= ƒA„ && ch <=„Z„)
                       cout<= ƒa„ && ch <=„z„)
                       cout<
						
									
										
									
																
													
					
The words contained in this file might help you see if this file matches what you are looking for:

...Chapter control statements i puc mdrpuc hassan introduction are that alter the sequence of flow instructions any single input statement assignment and output is simple a group separated by semicolon enclosed within curled braces called block or compound order in which executed program types c supports two basic o selection iteration this allows us to select set for execution based on some condition it also known as conditional structure helps programmer take appropriate decision different viz if elsestatement nested ifstatement switch simplest form one way branching used decide whether should be not can evaluated true false general test p g e here tested results either value result then otherwise ex amount discount net practical write find largest smallest second three numbers using include void main int b seclargest clrscr coutb assume first number...

no reviews yet
Please Login to review.