Skip to main content

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

  Marks  allotted : 05 Marks A. PROJECT GUIDELINES The aim of the class project is to create tangible and useful IT application. The learner may identify a real-world problem by exploring the environment. e.g. Students can visit shops/business places, communities or other organizations in their localities and enquire about functioning of the organization, and how data are generated, stored, and managed. The learner can take data stored in csv or database file and analyze using Python libraries and generate appropriate charts to visualize. If an organization is maintaining data offline, then the learner should create a database using MySQL and store the data in tables. Data can be imported in Pandas for analysis and visualization. Learners can use Python libraries of their choice to develop software for their school or any other social good. Learners should avoid plagiarism and violation of copyright issues while working on projects. Any resources (data, image etc.) used in t...

Assignments - XII Computer Science

POINTERS ASSIGNMENT Assignment Date: 09/09/15 Submission Date: 14/09/15 Q1. What will be the output of the following program: int main() { int x [ ] = { 50, 40, 30, 20, 10}: int *p, *t; p = x; t = x + 1; cout << *p << “,” << *t++; return 0; } Q2. What will be the output of the program( Assume all necessary header files are included) void print (char * p ) { p = "Comp"; cout<<"value is "<<p<<endl; } int main( ) { char * x = "Class XII"; print(x); cout<<"new value is "<<x<<endl; return 0; } Q3. Identify errors on the following code segment, and underline the error. float c[ ] ={ 1.2,2.2,3.2,56.2}; float *k,*g; k=c; g=k+4; k=k*2; g=g/2; cout<<”*k=”<<*k<<”*g=”<<*g; Q4. Write the output of the following program. void print (char * p ) { p = "Comp"; cout<<"valu...