Plus One Computer Application Chapter Wise Previous Questions Chapter 6 Introduction to Programming

Kerala Plus One Computer Application Chapter Wise Previous Questions Chapter 6 Introduction to Programming

Question 1.
In the following program, some lines are missing. Fill the missing lines and complete it. (March – 2015)

#include<iostream.h>
.................
{
int num1, num2, sum;
Cout<<“Enter two numbers:”;
....................
....................
Cout<<“sum of numbers are=”<<sum;
}

Answer:
The correct program is given below.

#include<iostream>
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;
}

Question 2.
The following program finds the sum of three numbers. Modify the program to find the average. (Average should display fractional part also.) (MARCH -2016)

#include<iostream>
using namespace std;
int main( )
{
int x, y, z, result; 
cout<<“Enter values for x, y, z”; 
cin>>x>>y>>z;
result=x+y+z;
cout<<“The answer is =”<<result; 
return( );
}

Answer:
float result
result = (x + y + z) / 3.0;

Question 3.
Which one of the following is NOT a valid C++ statement? (SAY -2016)
a) x = x + 10;
b) x + = 10;
c) x + 10 = x;
d) x = 10 + x;
Answer:
c) x + 10 = x;

Question 4.
What is implicit type conversation? Why it is called type promotion? (March – 2016)
Answer:
Type conversion : Type conversions are of two types.
1) Implicit type conversion-: This is performed by C++ compiler internally. C++ converts all the lower sized data type to the highest sized operand. It is known as type promotion. Data types are arranged lower size to higher size is as follows, unsigned int(2 bytes), int(4 bytes),long (4 bytes) , unsigned long (4 bytes), float(4 bytes), double(8 bytes), long double(10 bytes)

Question 5.
Comments in a program are ignored by the complier. Then why should we include comments? Write the methods of writing comments in a C++ program. (Say – 2016)
Answer:
To give tips in between the program comments are used. A comment is not considered as the part of program and cannot be executed. There are 2 types of comments single line and multiline.

Single line comment starts with //(2 slashes) but multi-line comment starts with /* and ends with */

Question 6.
if A = 5, B = 4, C = 3, D = 4, then what is the result in X after the following operation? (March – 2017)
X = A + B – C * D
OR
Is there any difference between (a) and (b) by considering the following statement?

char Gender;
a) Gender = ‘M’;
b) Gender = “M”;
Answer:
X = A + B – C * D
= 5 + 4 – 3*4
= 5 + 4 – 12(Reason :Multiplication has more priority than addition and subtraction).
= 9 – 12
= -3
OR
a) character constant ‘M’ is stored in the variable Gender.
b) “M” is a string constant hence it cannot be assigned by using an assignment operator. Use string function as follows strcpy(Gender,”Mn);

Plus One Computer Application Chapter Wise Previous Questions