Hsslive XI Comp App 06 Introduction To Programming
Hsslive XI Comp App 06 Introduction To Programming
INTRODUCTION TO PROGRAMMING
1. What is Pre-processor directive?
Pre processor are the compiler directive statements which direct the compiler to
process the information provided before actual compilation starts. They are lines
starts with # include in the program but not the part of it.
Header files contain information about functions, objects or derived data types
and are available along with compiler. .
The execution of C++ program begins at main () and ends within main (). All other
function used in the program are called from main ().
A variable is associated with two values, L-value, its address and R-value, its
content.
The const key word is used in the variable declaration to make its access read
only, ie we can’t change its value
Type modifiers are given in the variable declaration to alter the size , range and
precision of the variable. Important type modifiers are signed , unsigned, long and
short.
arithmetic assigned operators are C++ short hands used to represent arithmetic
binary operations such as +, - ,* , /.
By this method
Eg. --a; , a- -;
There are two forms of increment/decrement operators, prefix form and post fix
form.
So the incrementation /decrementation takes first and then the assignment takes
place(ie. Change and then use method)
c=a++; or c=-a- -;
It is the order of operations will carried out in C++ when different operations are
1. ( ) Parenthesis
2. ++, --, size of Unary operator
3. *, /, %
4. +, -
5. =, <, > etc Relational operators
6. ==, !=
7. &&
8. !!
9. ? :
10. =, += etc arithmetic assignment operator
11. , comma
6. Which header file is responsible for cout and cin objects? (1)
7. C++ program execution starts and ends within ......... function (1)
7. How do the type modifiers effect the size and range of int and char data types ? (2)
8. Briefly explain any two expressions in C++. (2)
x=-7 ,y=3
a)add –x with –y
b)x modulus y
9. If a = 5, b = 7 and c = 3, predict the output of the following expressions . (2)
a) a
b) b% a
c) (a>c) && (a<b)
d) a/c
10.Predict the value of ‘b’ in the following C++ code after execution of each code
snippet.
a) a=5 ; b= a++ ;
b) a=5 ; b=++a ; (2)
# include <iostream>
using namespace std;
int main ()
{
Int a = 10 ;
cout<<”\n a= “ << a--;
cout<<”\n a= “ << --a;
return 0;
} (2)
14. 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;
} (2)
15. Write sample statements in C++ for the cascading of input and output
operators. (2)
17. 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;
} (2)
#include<iostream.h>
...............................................
Int num1,num2,sum;
..................................................................
..................................................................
} (3)
19. a). Consider the structure of C++ program given below and answer the
following question.
#include<iostream>
int main( )
Statements;
20. Explain implicit and explicit type conversion with suitable examples. (3)
21. What are data types? Explain the fundamental data types in C++. (3)
22. What is the role of comments in a program? Explain the different ways to write
comments in a C++ program. (3)
24. Write a C++ program to check whether the given number is Prime or Not . (5)
25. Write a C++ program to find the total and percentage of a student in Six Subjects.(5)
© www.hsslive.in Prepared by Anil Kumar C , Govt HSS, Kuzhumathikkad, Kollam
© www.hsslive.in Prepared by Anil Kumar C , Govt HSS, Kuzhumathikkad, Kollam