written 8.7 years ago by |
Structured Programming Approach - Dec 2014
First Year Engineering (Semester 2)
TOTAL MARKS: 80
TOTAL TIME: 3 HOURS
(1) Question 1 is compulsory.
(2) Attempt any three from the remaining questions.
(3) Assume data if required.
(4) Figures to the right indicate full marks.
1 (a) Explain the difference in using call by reference and call by value methods for argument passing, for swapping 2 numbers.(8 marks)
1 (b) What is significance of storage class? Illustrate each storage class with example.(10 marks)
1 (c) Find the output of the following code:
main ()
{
int a[]={10,20,30,40,50};
int *j, *k;
j=&a[4];
k=(a+4);
if (j==k)
printf ("Both pointers points to same locations");
else
printf ("both pointers does not point to same locations");
}(2 marks)
2 (a) Choose the correct answer for the following:
(i) Parameters passed as arguments to the function call are called as
(a) Actual parameters
(b) No parameters
(c) Formal parameters
(d) None of these
(ii) Which of the following returns statement in function has error
(a) return
(b) return (expression)
(c) return (0)
(d) None of these
(iii) Which of the following is not jump statement
(a) for
(b) continue
(c) break
(d) goto
(iv) Which of the following is an exit controlled loop.
(a) for
(b) do-while
(c) while
(d) if-else
(v) In array a[2][3]={10,20,30,40,50} then a[0][1] element is
(a) 10
(b) 40
(c) 50
(d) 20(5 marks)
2 (b) Write a program using function to print first 'n' numbers in Fibonacci series.(5 marks)
2 (c) Define structure within structure consisting of following elements :-
(i) Employee code
(ii) Employee name
(iii) Employee salary
(iv) Employee date of joining.
Write a program to read at least 10 records and display them.(10 marks)
3 (a) Write a program to implement calculator with following operations:-
(i) Add two numbers
(ii) Division two numbers
(iii) Subtract two numbers
(iv) Multiply two numbers(6 marks)
3 (b) Write a program to find the GCD and LCM of 2 nos.(6 marks)
3 (c)
Write a program to print the following pattern. (Note: Not only 4 lines, it should print n line taken from user)
(i) !(5+5<10)
(ii) 5+5==10 || 1+3==5
(iii) 5.10|| 10<20 && 3<5(3 marks) 5 (b) An electric power distribution company charges its domestic consumer as follows:
Consumption Units | Rate of Charge |
0-200 | 0-50 per unit |
201-400 | Rs. 100 plus Rs. 0.65 per unit excess of 200 |
401-600 | Rs. 230 plus Rs. 085 per unit excess of 400 |
601- above | Rs. 390 plus Rs. 1.00 per unit excess of 600 |
Program should read the units consumed for a customer and calculate the total bill.(7 marks)
5 (c) Four experiments are performed, each experiment consisting of six test results. The result for each experiment follows. WAP to compute and display the average of the test results for each experiment.
1st Experiment results | 23.2 | 31.5 | 16.9 | 28.0 | 26.3 | 28.2 |
2nd Experiment results | 34.8 | 45.2 | 20.8 | 39.4 | 33.4 | 36.8 |
3rd Experiment results | 19.4 | 50.6 | 45.1 | 20.8 | 50.6 | 13.4 |
4th Experiment results | 36.9 | 42.7 | 20.8 | 10.2 | 16.8 | 42.7 |
(10 marks) 6 (a) Explain with example bitwise operators in C language.(5 marks) 6 (b) Write a program using recursive function 'power' to compare xn
power (x,n)=1 | if n=0 |
power (x,n)=x | if n=1 |
power (x,n)=x*power(x, n-1) | otherwise |
(8 marks) 6 (c) Write a user defined function to copy one string to another.(4 marks) 6 (d) What is a File? What are the different mode in which we can open a file? What are the different functions to read and write to file?(3 marks)