written 8.7 years ago by |
Structured Programming Approach - May 2012
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)(i) What will be the output of the following:-
#include <stdio.h>
void show(int a, int b, int c){
printf("%d %d %d", a, b, c);
}
int j;
int i = &j;
j = 2;
int k[] = {1, 2, 3};
void main(){
show(i, j, k);
}</stdio.h>(2 marks)
1 (a)(ii) Select the correct option: A class becomes abstract when
(i) Keyword abstract preceeds the class name
(ii) All the functions in the class are pure virtual
(iii) Atleast one function in the class is pure virtual
(iv) It derives virtually from base class.(2 marks)
1 (a)(iii) What is the output of the following code:-
#include <stdio.h>
#define m(a, b)(a > b ? a : b)
void main(){
int i = 5, j = 15;
printf("%d", m(++i, j++));
}</stdio.h>(2 marks)
1 (a)(iv) Write the output of the following:-
#include <stdio.h>
void swap(int i, int j){
int temp = i; i = j; j = temp;
}
void main(){
int k = 13, m = 45;
swap(k, m);
printf("k = %d, m = %d", k, m);
}</stdio.h>(2 marks)
1 (a)(v) while(expression){}
To terminate this loop, the value of the expression should evaluate to true or false?(2 marks)
1 (b) Discuss the merits and demerits of Object Oriented Methodology.(10 marks)
2 (a) Write a program to find number of and sum of all integers greater than 200 and less than 350 that are divisible by 9. (10 marks)
2 (b) Write a program that reads an integer N followed by N numbers. It prints each number and the sum of numbers read so far.(10 marks)
3 (a) Differentiate between structures and unions from the operations on them and memory allocation point of view.(10 marks)
3 (b) Write a program to represent and process complex numbers as a structure. Process should include adding complex numbers and printing them in x + iy format.(10 marks)
4 (a) Write a method called delete(String str, int m) in an appropriate class that requires the input string with mthcharacter removed.(10 marks)
4 (b) Explain various storage classes in C.(10 marks)
5 (a) Class string has a data member str of type char. Distinguish from the point of view of constructors following statements:-
(i) String name1("XYZ");
(ii) String name2(name1);(10 marks)
5 (b) What are destructors? State the necessity in 5(a).(10 marks)
6 (a) Write a program to add two matrices.(10 marks)
6 (b) Explain binary operator overloading using suitable example.(10 marks)
Write short notes on any two:-
7 (a) Runtime polymorphism(10 marks) 7 (b) Data Abstraction & Encapsulation(10 marks) 7 (c) Friend function(10 marks)