Class XI B [CS] Assignment ' if else '

1.         Find error in code below and explain.
            #include<iostream.h>

            void main()
             { 
                        int x = 5 ;  
                        if( x > 5 ) 
                        { 
                           x += 5; 
                           int y = 8; 
                        } 
                        y += x; 
            }

2.         Find the output of the code below :
            void main( )
            {
                        int NoOfGirls = 4;
                        int NoOfBoys = 10 ;                                                                                
                       
                        if ( NoOfBoys =  8    &&    NoOfGirls <= NoOfBoys )
                                    cout<<”Great achievement”;
                        else
                                    cout<<”Greater achievement”;
            }

3.         Find the output of the code below :
            void main( )
            {
                        int circle = 5 , rectangle = 0 , square = 4 , triangle = 0 ;
                        if( circle)
                        {
                                    if( rectangle || square )
                                    {
                                                cout<<”Draw diagram”;
                                    }
                                    else if( ! rectangle  && ! square )
                                    {
                                                cout<<”Invalid diagram”;
                                    }
                                    else
                                    {
                                                if( circle == rectangle || square == triangle )
                                                {
                                                    cout<<”Canvas Available”;
                                                }
                                    }
                        }
                        cout<<”Invisible diagram”;
            }    
                        

4.         Find the output of code below:

            void main( )
            {
                        int x = 3 , y = 5;
                        if( x <= 5 );
                          cout<<”Hurray”;
                        else
                          cout<<” Trapped”;
            }

5.    Mahalaxmi wants to check whether her weight is an odd number or even. Write a code for this.


6.    Write a
 program to find whether a 4 digit input-ed year is a leap year.
NOTE: A leap is a year which :
  i ) is divisible by 4 but not divisible by 100
  ii) is divisible by 4 as well as divisible by 100 and at he same time divisible by 400


7.   Write a program to compare three integer values to find highest out of them.

Popular posts from this blog

Project Work for Class XII Informatics Practices (065) - CBSE 2020-2021

Assignments - XII Computer Science