0
1.2kviews
Structured Programming Approach Question Paper - May 18 - First Year Engineering (Semester 2) - Mumbai University (MU)
1 Answer
0
8views

Structured Programming Approach - May 18

First Year Engineering (Semester 2)

Total marks: 80
Total time: 3 Hours
INSTRUCTIONS
(1) Question 1 is compulsory.
(2) Attempt any three from the remaining questions.
(3) Draw neat diagrams wherever necessary.

1.a. Select the correct option from multiple choice questions.

1.a.i. Which bitwise operator is used to multiply the number by 2n where n is number of bits.

A] Bitwise-OR

B] Bitwise-AND

C] Bitwise Left shift

D] Bitwise Right Shift


1.a.ii. Which operator has the lowest priority?

A] ++

B] %

C] +

D] ||


1.a.iii. Which of these is a valid variable declaration?

A] int emp salary; B] float marks_student; C] float roll-no; D] int main;


1.a.iv. What will be the output of the following program?

void main ( ) {
double x=28;
int r;
r= x%5;
printf ("\n r=%d", r);
}

A] r= 3

B] Run time Error

C] Compile time Error

D] None of the Above


1.a.v. What will be the output of the program

void main() {
int X []= {10,20,30,40,50};
print f (" \n %d %d %d %d ", x [4] ,3[x] ,x[2] ,l[x] ,x[0] );
}

A] Error

B] 10 20 30 40 50

C] 50 40 30 20 10

D] None of these


1.a.vi. Which of the following is not a keyword of 'C' ?

A] auto

B] register

C] int

D] function


1.a.vii. What will be the output?

void main ( ) {
int y;
y=0xl0+ 010+10;
printf ("\ny=%x", y);
}

A] y = 34

B] x = 34

C] y = 22

D] Error


1.a.viii. Study the following C program

void main () {
int a= 0;
for ( ; a ;); a++; 
}

What will be the value of the variable a, on the execution of the above program.

A] 1

B] 0

C] -1

D] none of these


1.a.ix. Which of the following is used as a string termination character?

A] 0

B] \0

C] /0

D] None of these


1.a.x. What will be the output of the following program code?

void main ( ) { 
char a[]= "Hello World" ; 
char *p ; 
p=a; 
printf("\n%d %d %d %d", sizeof(a), sizeof(p), strlen(a), strlen(p) );
}

A] 11 11 10 10

B] 10 10 10 10 10

C] 12 12 11 11

D] 12 2 11 11

(10 marks) 00

1.b. State True or False with reason.

i. Size of pointer variable is equal to the datatype it points to.

ii. A float constant cannot be used as a case constant in a switch statement.

iii. The statement void p; is valid.

iv. while {0); is an infinite loop.

v. scanf() function is used to input string having multiple words

vi. A function can have any number of return statements.

vii. In a union, space is allocated to every member individually.

viii. An algorithm is a graphical representation of the logic of a program.

ix. Comments in the program make debugging of the program easier.

x. There is no difference between '\0' and '0'.

(10 marks) 00

2.a.i. How to create array of structure variables and assign values to its members?
(5 marks) 12220

2.a.ii. Differentiate between struct and union. When is union preferred over struct? 5 Give one example of each.
(5 marks) 12210

2.b.i. WAP to print the sum of the following series:

$1 + 2^2 + 3^3 + ... + n^n$

(5 marks) 12182

2.b.ii. Compare the following:

i) break and continue statements

ii) if-else and switch statements

(5 marks) 12183

3.a. Write a program to calculate number of vowels (a, e, i, o, u) separately in the 6 entered string.
(6 marks) 12227

3.b.i. Predict output of following program segment. [Note: Show pictorial representation]

1) main() { int a,b,pl,p2,x,y; a=48;b=lO;pl=&a;p2=&b; x=pl *p2-8; pl=pl+p2; y=(pl/*p2)+20; printf("%d %d %d %d %d %d", *pl, *p2,a,b,x,y); }

2) main() {
int x=4,y=9,z; 
z = x++ + --y +y; 
printf("\n %d %d %d",x,y,z); z= --x + x+ y--; 
printf("\n %d %d %d",x,y,z); 
}

(2 marks) 12202

3.c. An electronic component vendor supplies three products: transistors, resistors and capacitors. The vendor gives a discount of 10% on order for transistors if the order is more than Rs. 1000. On order of more than Rs. 100 for resistors, a discount of 5% is given and discount of 10% is given on orders for capacitors of value more than Rs. 500. Assume numeric code 1, 2 and 3 used for transistors, capacitors and resistors respectively. Write a program that reads the product code and the order amount, and prints out the net amount that the customer is required to pay after discount. (Note: Use switch-case)
(10 marks) 12181

4.a. What is recursion? WAP using recursion to find sum of array elements of size n.
(10 marks) 12228

4.b. Write a C program to

  • i. Create a 2D array (Matrix) [in main function]
  • ii. Write a function to read 2D array(Matrix)
  • iii. Write a function that will return true(l) if entered matrix is symmetric or false(0) is not symmetric.
  • iv. Print whether entered matrix is symmetric or not [ in main function]

(5 marks) 12218

5.a. Implements string copy function STRCOPY (strl, str2) that copies a string strl (source) to another string str2 (destina!ion) without using library function.
(5 marks) 12219

5.b. Explain File handling in c in detail. [Note: Mention file types, file modes, file related functions and its use].
(8 marks) 12200

5.c. WAP to print all possible combinations of 1, 2, 3 using nested loops.
(7 marks) 12179

6.a. WAP to print following pattern for n lines. [Note: range of n is 1-9]

enter image description here

(5 marks) 12180

6.b. WAP to print binary equivalent of entered decimal no.
(5 marks) 12194

6.c. What is significance of storage classes? Explain it with relevant example
(10 marks) 12229

Please log in to add an answer.