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

Students can Download Chapter 6 Introduction to Programming Questions and Answers, Plus One Computer Application Chapter Wise Questions and Answers helps you to revise the complete Kerala State Syllabus and score more marks in your examinations.

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

### Plus One Computer Application Introduction to Programming 1 Mark Questions and Answers

Question 1.
From the following which is ignored by the compiler
a) statement
c) loops
d) None of these

Question 2.
Multi line comment starts with ____ and ends with
a) /’ and’/
b)*/and/*
c) /* and*/
d)’/ and /’
c) /* and*/

Question 3.
Single line comment starts with _____.
a) **
b)@@
c) */
d) //
d) //

Question 4.
Alvin wants to store the value of π From the following which is correct declaration
a) char pi=3.14157
b) const int pi=3.14157
c) const float pi=3.14157
d) long pi=3.14157
c) const float pi=3.14157

Question 5.
To store 70000 which modifier is used with int.
a) long
b) short
c) big
d) none of these
a) long

Question 6.
To store 60000 which modifier is used with int.
a) unsigned
b) short
c) big
d) none of these
a) unsigned

Question 7.
Consider x++(post fix form). Select the correct definition from the following
a) The operation is performed after the value is . used
b) The operation is performed before the value is used
c) First change then use
d) None of these
a) The operation is performed after the value is used

Question 8.
Consider ++x(pre fix form). Select the correct definition from the following
a) The operation is performed after the value is used
b) The operation is performed before the value is used
c) First use then change
d) None of these
b) The operation is performed before the value is used

Question 9.
Consider the following
int a=10;
float b=4;
cout<<a/b;
We know that the result is 2.5 a float. What type of conversion is this ?
a) type promotion
b) type casting
c) explicit conversion
d) None of these
a) type promotion(implicit conversion)

Question 10.
From the following which has the major priority?
a) ++
b) =
c) ==
d) &&
++

Question 11.
From the following which has the major priority?
a) ++
b) =
c) ==
d) &&
++

Qn. 11
One of your friend told you that post increment (eg:x++) has more priority than, pre increment (eg: ++x).
State True / False
It is true.

Question 12.
Emerin wants to store a constant value. Which key word is used for this?
constant.

Question 13.
Suppose x= 5. Then cout<<x++ displays _____.
Here post increment first use the value then incremented

Question 14.
Suppose x= 5. Then cout<<++x displays _____.
6. Here pre increment first incremented and then use the value.

Question 15.
Pick the odd one out :
a) long
b) short
c) unsigned
d) int
d) int. it is fundamental data type and the others are type modifiers

Question 16.
Memory size and sign can be changed using ______ with fundamental data types.
Type modifiers

Question 17.
“Its value does not change during execution”. What is it?
constant.

Question 18.
“BVM HSS” is called ______.
а) integer constant
b) float constant
c) string constant
d) None of these
c) string constant

Question 19.
he address of a variable is called ______.
L-value (Location value) of a variable

Question 20.
The content of a variable, is called _____.
R-value (Read value) of a variable

Question 21.
Suppose the address of a variable age is 1001 and the content i.e. age = 33. Then what is R-value and L-value?
R-value is 33 and L-value is 1001

Question 22.
is it possible to declare a variable as and when a need arise . What kind of declaration is this ?
Yes.lt is known as Dynamic declaration

Question 23.
In the following program, some lines are missing. Fill the missing lines and complete it.
#include<iostream.h>
{
4 int num1, num2, sum;
Cout<<“Enter two numbers:”;
…………..
…………
Cout<<“sum of numbers are=”<<sum;
}
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 24.
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 for x, y, z”;
cin>>x>>y>>z;
result=x+y+z;
return 0;
}
float result
result = (x + y + z) / 3.0;

Question 25.
Some of the C++ statements given below are invalid. ,
i) cin>>m, n;
ii) a + b = c;
iii) void p;
iv) cout<<28;
Identify them from the following alternatives:
a) Statement (i) and (ii) only
b) Statement (Ii) and (iii) only
c) Statement (i), (ii) and (iii) only
d) All the statements
c) Statement (i); (ii) and (iii) only

Question 26.
Which one of the following is NOT a valid C++ statement?
a) x = x+ 10;
b) x + = 10;
c)x+10 = x;
d) x=10 + x;
c)x+10 = x;

### Plus One Computer Application Introduction to Programming 2 Marks Questions and Answers

Question 1.
What do you mean by pre processor directive?
A C++ program starts with the pre processor directive i.e., # include, #define, #undef, etc, are such a pre processor directives. By using #include we can link the header files.that are needed to use the functions. By using #define we can define some constants.
Eg: #define x 100.
Here the value of x becomes 100 and cannot be changed in the program.

### Plus One Computer Application Introduction to Programming 3 Marks Questions and Answers

Question 1.
We know that a program has a structure. Explain the structure of C++program.
A typical C++ program would contain four sections as shown below.
Include files
Function declarations
Function definitions
Main function programs
Eg:
#include<iostream>
using namespace std;
int sum(int x, int y)
{
return (x+y);
}
int main( )
{
cout<<sum(2,3);
}

Question 2.
Write a program to print a message as” Hello, Welcome to C++”.
#include<iostream>
using namespace std;
int main( )
{
cout<<” Hello, Welcome to C++”;
}

Question 3.
Following is a sample C++ program. Identify the errors if any in the structure. Correct the program..
#include<iostream>
using namespace std;
int main [ ]
{
*/ It is a simple program */
Cout<< “Welcome to C++”
Cout<< “The End” .
}
The multi line comment used in this program is wrong. So the correct code is as follows
#include<iostream>
using namespace std;
int main ( )
{
/* It is a simple program */
cout<< “Welcome to C++”
cout<< “\nThe End”
}

Question 4.
Write a program to read two numbers and find its sum.
#include<iostream>
using namespace std;
int main( )
{
int n1,n2,sum;
cout<<“Enter two numbers”;
cin>>n1>>n2;
sum=n1+n2;
cout<<“The sum of “<<n1<<” and “<<n2<<” is “<<sum;
}

Question 5.
Write a program to read three scores and find the average.
#include<iostream>
using namespace std;

int main( )
{
ints1,s2,s3;
float avg;
cout<<“Enter the three scores”;
cin>>s1>>s2>>s3;
avg=(s1 +s2+s3)/3.0;
cout<<“The average CE score is “<<avg;
}

Question 6.
Write a program to find the area and perimeter of a circle.
#include<iostream>
using namespace std;
int main( )
{
const float pi=3.14157;
float r,area,perimeter;.
cout<<“Enter the radius of a circle”;
cin>>r;
area=pi*r*r;
perimeter= 2*pi*r;
cout<<“Area of the circle is”<<area<<“\nPerimeter of the circle is “<<perimeter;
}

Question 7.
Write a program to find the simple interest.
#include<iostream>
using namespace std; ,
int main( )
{
float p,n,r,si;
cout<<“Enter the Principal amount”;
cin>>p;
cout<<“Enter the number of years”;
cin>>n;
cout<<“Enter the rate of interest”;
Cin>>r;
si=p*n*r/100;
cout<<“Simple interest is “<<si;

Question 8.
Write a program to convert temperature from Celsius to Fahrenheit.
#include<iostream>
using namespace std;
int main( )
{
float c,f;
cout<<“Enter the Temperature in Celsius:”;
cin>>c;
f=1,8*c+32;
cout<<c<<” Degree Celsius = “<<f<<” Degree Fahrenheit”;
}

Question 9.
Write a program to read weight in grams and convert it into Kilogram.
#include<iostream>
using namespace std;
int main( )
{
float gm.kg;
cout<<“Enter the weight in grams:”;
cin>>gm; kg=gm/1000;
cout<<gm<<” grams = “<<kg<<” Kilograms”;
}

Question 10.
Write a program to generate the following table.

Use a single cout statement for output
#include<iostream>
using namespace std;
int main( )
{
cout<<“2013\t100%\n2012\t99.9%\n2011 \t95.5%\n2010\ t90.81 %\n2009\t85%”;
getch( );
}

Question 11.
Write a program to read your height in meter and cm convert it into Feet and inches
#include<iostream>
using namespace std;
int main( )
{
int m,cm;
float inch;
int feet;
cin>>cm;
cout<<” Your height is “<<cm/100<<” Meters and “<<cm%100<<” cm \n”;
inch=cm/2.54;
feet=inch/12;
inch=(int)inch%12;
cout<<feet<<“feet and”<<inch<<” inch”;
}

Question 12.
Write a program to find the area of a triangle Triangle .
#include<iostream>
using namespace std;
int main( )
{
intb,h;
float area;
cout<<“Enter values for b and h”;
cin>>b>>h;
area=0.5*b*h;
cout<<“The area of the triangle is “<<area;
}

Question 13.
Write a program to find simple interest and compound interest.
#include<iostream>
using namespace std;
#include<cmath>
int main( )
{
float p,n,r,si,ci;
cout<<“Enter the Principal amount”;
cin>>p;
cout<<“Enter the number of years”;
cin>>n;
cout<<“Enter the rate of interest”;
cin>>r;
si=p*n*r/100;
ci=p*pow((1+r/100),n)-p;
cout<<“Simple interest is “<<si;
cout<<“\nThe compound interest is “<<ci;
}

Question 14.
Write a program to
i) print ASCII for a given digit
ii) print ASCII for backspace.
#include<iostream>
using namespace std;
int main( )
{
char ch;
intasc.bak;
cout<<“Enter a digit:”;
cin>>ch;
asc=ch;
cout<<“ASCII for “<<ch<<” is “<<asc;
bak=’\b’;
cout<<“\nASCII for backspace is “<<bak;
}

Question 15.
Write a program to read time in seconds and convert it into hours, minutes and seconds .
#include<iostream>
using namespace std;
int main( )
{
long h,m,s;
cout<<“Enter the time in seconds:”;
cin>>s;
h=s/3600;
s=s%3600;
m=s/60.;
s=s%60;
cout<<h<<” hr:”<<m<<” min:”<<s<<” secs”;
}

Question 16.
Consider the following ‘
int a=45.65;
cout<<a;
What is the output of the above. Is it possible to convert a data type to another type? Explain.
The output of the code is 45, the floating point number is converted into integer. It is possible to convert a data type into another data type. Type conversions are 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)

2) Explicit type conversion : It is known as type casting. This is done by the programmer. The syntax is given below.
(data type to be converted) expression
Eg. intx=10;
(float)’x; This expression converts the data type of the variable from integer to float.

Question 17.
Match the following numbers and data types in C++ to form the most suitable pairs.

 1) 142789 a) Signed 2) 240 b) Double 3) -150 c) Long int 4) 8.4×10-4000 d) Float 5) 0 e) Long double 6) 0.0008 f) Unsigned short 7) -127 g) Short int 8) 2.8×10308 h) Signed char

 1) 142789 a) Long int 2) 240 b) Short int 3) -150 c) Signed 4) 8.4×10-4000 d) Long double 5) 0 e) Unsigned short 6) 0.0008 f) Float 7) -127 g) Signed char 8) 2.8×10308 h) Double

Question 18.
Determine the data type of the following expression.
If a is an int, b is a float, c is a long int and d is a double
$$\frac{(1-a c)^{25}}{(c-d)}+\frac{(b+a) / c}{(l o n g)(a+d)}$$
In type promotion the operands with lower data type will be converted to the highest data type in the expression. So consider the following,

=double + long
= double (Which is the highest data type)

Question 19.
What is implicit type conversation? Why it is called type promotion?
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 20.
Area of a circle is calculated using the formula πr², where π =3.14 and r is the radius of the circle. Fill in the blanks in the following program which finds the area of a circle.
void main ( )
{
cin ………..
area = …………
cout …………
}

Question 21.
With the help of an example, explain type casting in C++ programs?
The output of the code is 45, the floating point number is converted into integer. It is possible to convert a data type into another data type. Type conversions are 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)

2) Explicit type conversion : It is known as type casting. This is done by the programmer. The syntax is given below.
(data type to be converted) expression .
Eg. int x=10;
(float) x; This expression converts the data type of the variable from integer to float.

Question 22.
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.
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 23.
if A = 5, B = 4, C = 3, D = 4, then what is the result in X after the following operation?
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”;
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 Introduction to Programming 5 Marks Questions and Answers

Question 1.
Two pairs C++ expressions are given below.
i) a=10 a==10
ii) b=a++, b=++a
a) How do they differ?
b) What will be the effect of the expression ?