+1 and +2 Computer Science

Previous Question paper answered , and Questions from Textbook

+1 and +2 Computer Application

Previous Question paper answered , and Questions from Textbook

Diploma in Computer Application (DCA)

Previous Question paper answered , and Questions from Textbook.

Master of Computer Applications (MCA)

Previous Question paper answered , and Questions from Textbook

True IQ Computer Online Academy

Contact : +91 9036433020 , mail2trueiq@gmail.com

Pageviews

Showing posts with label Introduction To Programming. Show all posts
Showing posts with label Introduction To Programming. Show all posts

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.


+1] 6 . Introduction To Programming - Solved Questions from text book

                        PLUS ONE COMPUTER APPLICATION

Chapter 6  Introduction To Programming
                           (+1. Computer Application Questions and  answers from text book)                                                                                         

1. What is dynamic initialisation of variables?

        A variable can also be initialised during the execution of the program and is known as dynamic initialisation. This is done by assigning an expression to a variable as shown in the following statements: 
float product = x * y;
 float interest= p*n*r/100.0;

   In the first statement, the variable product is initialised with the product of the values stored in x and y at runtime. In the second case, the expression p*n*r/100.0 is evaluated and the value returned by it will be stored in the variable interest at runtime.

 2. What is type promotion?

         Implicit type conversion is performed by C++ compiler internally. In expressions where different types of data are involved, C++ converts the lower sized operands to the data type of highest sized operand. Since the conversion is always from lower type to higher, it is also known as type promotion. Data types in the decreasing order of size are as follows: long double, double, float, unsigned long, long int, unsigned int, int and short int. The type of the result will also be the type of the highest sized operand. 

 3. What do you mean by type casting? What is type cast operator?

   Unlike implicit type conversion, sometimes the programmer may decide the data type of the result of evaluation. This is done by the programmer by specifying the data type within parentheses to the left of the operand. Since the programmer explicitly casts a data to the desired type, it is also known as explicit type conversion or type casting.
A cast is a special operator that forces one data type to be converted into another. As an operator, a cast is unary and has the same precedence as any other unary operator. The most general cast supported by most of the C++ compilers is as follows − (type) expression.

4. What type of variable declaration is used in the following program code ?

 { int area, length = 10, width = 12, perimeter; 

 area = length * width;

 perimeter = 2*(length + width);

 }

 2. Modify the above program code to have dynamic initialisation for variables area and perimeter.

    {
       int area =length*width;

       int perimeter =2*(length*width);

}

 3. Explain type modifiers in C+ +.

          In C++ too, we need data types that can accommodate data of slightly bigger/smaller size. C++ provides data type modifiers which help us to alter the size, range or precision. Modifiers precede the data type name in the variable declaration. It alters the range of values  permitted to a data type by altering the memory size and/or sign of values. Important modifiers are signed, unsigned, long and short. The exact sizes of these data types depend on the compiler and computer you are using. 

It is guaranteed that:

 • a double is at least as big as a float. 

• a long double is at least as big as a double.
 4. Why are so many data types provided in C++? 

5. What is the role of the keyword 'const'? 

         The keyword const is used to create such symbolic constants whose value can never be changed during execution.

6. Explain pre increment and post increment operations. 

               Increment operator (++) This operator is used for incrementing the content of an integer variable by one. This can be written in two ways ++x (pre increment) and x++ (post increment). Both are equivalent to x=x+1 as well as x+=1.

7. Explain the methods of type conversions.

         Type conversion and can be done in two ways: implicitly and explicitly.

 Implicit type conversion (Type promotion) :Implicit type conversion is performed by C++ compiler internally. In expressions where different types of data are involved, C++ converts the lower sized operands to the data type of highest sized operand. Since the conversion is always from lower type to higher, it is also known as type promotion. Data types in the decreasing order of size are as follows: long double, double, float, unsigned long, long int, unsigned int, int and short int. The type of the result will also be the type of the highest sized operand.

Explicit type conversion (Type casting) : Unlike implicit type conversion, sometimes the programmer may decide the data type of the result of evaluation. This is done by the programmer by specifying the data type within parentheses to the left of the operand. Since the programmer explicitly casts a data to the desired type, it is also known as explicit type conversion or type casting. Usually, type casting is applied on the variables in the expressions. The data type compatibility is to be seriously considered in assignment statements where expressions are involved.

 8. If the file iostream.h is not included in a program, what happens?

         The header file iostream contains the information about the objects cin and cout. Eventhough header files have the extension .h, it should not be specified for GCC. But the extension is essential for some other compilers like Turbo C++ IDE. 

 9. What would happen if main() is not present in a program? 

         Every C++ program consists of a function named main(). The execution starts at main() and ends within main(). If we use any other function in the program, it is called (or invoked) from main(). Usually a data type precedes the main() and in GCC, it should be int. The function header main() is followed by its body, which is a set of one or more statements within a pair of braces { }. This structure is known as the definition of the main() function. Each statement is delimited by a semicolon (;). The statements may be executable and non-executable.

10. Identify the errors in the following code segments

 i. int main ( ) 


 cout << "Enter two numbers" ---------->

cin >> num >> auto  -------------->

float area = Length * breadth ; 



ii.

 #include <iostream>

using namespace; -------------->

 int Main()  --------------------->

{

 int a, b ------------------->

 cin <<a> >b  ------------->

 max = a % b  --------------->

 cout > max  -------------->



 Arrow marks all are errors. you find out and correct it.


11. Write the working of an assignment operator? Explain all arithmetic assignment operators with the help of examples.