Pageviews

Friday 6 September 2019

+1].6 . Introduction To Programming - Previous Questions chapter wise



                         PLUS ONE COMPUTER APPLICATION 
            First Year Computer Application(Commerce) Previous Questions Chapter wise ..


                                         Chapter  6  Introduction  To Programming



1.  What is the name files created to support C++ programs and kept in the  standard library 

2.  In C++ which among the following is NOT a rule for a valid idea

a)The first character must be a letter or underscore(_).

 b)White space and special characters are not allowed

 c)Keywords can be used as an identifier

d)Upper and lower case can be treated differently. 

Ans. c

3.  The arithmetic assignment operation Y/=10 is equivalent to ...................

 a) Y=10

 b) Y=Y+10

 c) Y=Y/10

 d) None of these

    Ans. c

4. .Which of the following is not a C++ statement?

a). x = x + 10;

 b). x + = 10;

c). x + 10 = x; 

d). x = 10+ x;

 Ans. c

5.  Which header file is responsible for cout and cin objects?

   Ans. <iostream>

6.  C++ program execution starts and ends within ......... function

   Ans. main( )

7. Write output of the following program?

# include <iostream>

 using namespace std;

 int main ()

{  Int  a = 10 ;

cout<<”\n a= “ << a--;

  cout<<”\n a= “ << --a;

 return 0;
             }

Ans. output

         10, 8

8.  The following program finds the sum of three numbers. Modify the program  to find the average. (Average should display fractional part also).

 #include<iostream>

using namespace std;

int main ( )

  { int x ,y , z, result;

 cout<<"Enter values f or x ,y, z" ;

 cin>>x>>y>z;

result=x+y+z;

cout<<"The answer is ="<<result;

 return 0; 



 Average of 3 numbers

#include<iostream>

using namespace std;

int main ( )

  {
 int x ,y , z;

 float avg;

 cout<<"Enter values for x ,y, z" ;

 cin>>x>>y>z;

avg = (x+y+z)/3;

cout<<"The answer is ="<<avg;

 return 0; 



9.  Detect and correct the errors in the following C++ code.

  #include<iostream>

 using namespace std;

int main ( )

 {   

int a, b; 

 cout<<” Enter two numbers: “;

   cin>>a and b; 

 a + b = c;

  cout<<"Sum = “<<c;

  return 0;     

  }   


 Ans.

    #include<iostream>

 using namespace std;

int main ( )

 {   

int a, b,c; 

 cout<<" Enter two numbers:'';

   cin>>a >> b; 

  c= a+b;

  cout<<"Sum = “<<c;

  return 0;     

  }

10. .In the following program,some lines are missing.Fill the missing lines and      complete it.

     #include<iostream.h>

...............................................

{

Int num1,num2,sum;

cout<<”Enter two numbers:”;

..................................................................

..................................................................

Cout<<”Sum of numbers are =”<<sum;

}   


Ans.

        #include<iostream.h>

using namespace std;
 int main( )
{

int num1,num2,sum;

cout<<”Enter two numbers:”;

cin>>num1>>num2;

sum= num1+num2;

Cout<<”Sum of numbers are =”<<sum;

return 0;




11.  a). Consider the structure of C++ program given below and answer the following question.
                   #include<iostream>
            using namespace std;
           int main( )
   {
    Statements;
   }
  Write the preprocessor directive statement in the code?   
       b). Explain the header files in a program


Ans. a. #include

   b. Header files contain  information  about functions, objects or derived data types and are available along with compiler.

12. Explain the difference between float g=9.8 ; and const float g=9.8?

           The const key word is used in the variable declaration  to make its access read only, ie we can’t change its value.
 example const float g= 9.8

     So const is known as access modifier.

  But float g=9.8 is not a constant value.It change its value.