LOYOLA COLLEGE (AUTONOMOUS), CHENNAI – 600 034
B.Sc. DEGREE EXAMINATION – STATISTICS
|
FIFTH SEMESTER – NOV 2006
ST 5401 – C AND C ++
(Also equivalent to STA 401)
Date & Time : 06-11-2006/9.00-12.00 Dept. No. Max. : 100 Marks
Part A
Answer all the questions. 10 X 2 = 20
- What are the special characters in C?
- Distinguish between string and character constants.
- Explain briefly increment operator with an illustration.
- Explain briefly “if…else” statement with an illustration in C.
- What is the output of the following?
int x = 0;
for (i=1; i<=5; i++)
{
x+=i*i;
printf(“%d”,x);
}
What will be the output when the above segment is executed?
- What are the logical expressions in C programming?
- int y =0, int k;
for (i=10; i>1; i++)
{
k=i*i;
cout<<k<<endl;
}
What will be the output when the above segment is executed?
- Write a C++ program to display the following output using a single cout statement.
Maths = 98
Physics=79
Statistics=99
- Define class.
- Define encapsulation.
Part B
Answer any five questions. 5 X 8 = 40
- Electricity charges are levied in a state according to the following schedule.
Number of Units consumed Rate / Unit
0 – 99 Rs. 1.50
- 2.50
300 – 499 Rs. 4.00
500 & above Rs. 5.00
Write a C program to prepare the electricity bill, when the number of units
consumed by a customer is given.
- Write a C program to find out the largest number from the three given numbers using an user-defined function.
- Explain the following control statement in C programming with an example.
a). do while
b). for statement.
- Explain one-dimensional arrays and write any one program of your choice in C with help of the same.
- Write a program to find perimeter and area of circle with help of function. ( note: area=pr2 and perimeter = 2pr)
- Calculate mean for the following data with help of C++ program.
X: 10 20 30 40 50 60 70 80 90 100
F: 2 8 9 15 25 40 30 20 18 10
- In a company the health insurance premium is deducted from salary as given in the following table:
Category Amount deducted (in %)
Single 9.75
Married without children 16.25
Married with children 24.50
Write a C++ program to receive as input the salary and category of a person and
calculate his insurance premium.
- Write C++ program to calculate standard deviation for N values using array in Class.
Part C
Answer any two questions. 2 X 20 = 40
- a). Explain different types of constants and their rules in C programming.
b). Write a C program to calculate mean and variance for N values with the help of arrays. (10+10)
- a). Write a C++ program to calculate sum of two matrices of order N X N.
b). When the principal, rate of interest and period of deposit are given, write a c
program to compute the simple interest and compound interest. (10+10)
- a). Explain function overloading.
b). Write C++ program to calculate area of a triangle with help of function
overloading when (i) two sides and (ii) three sides are known. (5+15)
- Write a C++ program to calculate correlation coefficient of two variable X and Y
and also display mean of X and Y using the concept of class. (10+5+5)