DipIETE – CS (OLD SCHEME)

 

Code: DC05                                                     Subject: PROBLEM SOLVING THROUGH ‘C’

Flowchart: Alternate Process: DECEMBER 2009Time: 3 Hours                                                                                                     Max. Marks: 100

 

 

NOTE: There are 9 Questions in all.

·      Question 1 is compulsory and carries 20 marks. Answer to Q.1 must be written in the space provided for it in the answer book supplied and nowhere else.

·      Out of the remaining EIGHT Questions answer any FIVE Questions. Each question carries 16 marks.

·      Any required data not explicitly given, may be suitably assumed and stated.

 

 

Q.1       Choose the correct or the best alternative in the following:                                   (2x10)

                

a.       What is the name of built-in function for finding square roots?

                                                                                                                                                      

                   (A)  square(x)                                      (B)  sqrt(x)

(C)    sqr(x)                                          (D) No built-in function

       

b.      A global variable is a variable

  

(A)    declared in the main( ) function.

(B)  declared outside the body of every function.

                   (C)  declared in any function other than the main( ) function.          

                   (D)  declared anywhere in the C program.     

 

             c.   Choose the function that returns remainder of a/b 

                  

(A)    remainder( )                                 (B)  mod( )

(C)  modulus( )                                    (D)  rem( )

 

             d.   Which among the following expression uses bitwise operator?

                  

(A)    a++                                            (B)  !a>5

(C)  a|b                                               (D)  a!=b

                                                               

             e.   printf( ) and scanf( ) belong to

                                

(A)     stdio.h                                          (B)  string.h

(C)  ctype.h                                         (D)  conio.h

 

             f.    What will be the output

                   main( )

                   {

int ct=13;

for(; ct; ;)

{

ct--;

}

printf(“%d\n”,ct);

}

                  

(A)     2                                                  (B)  1

(C)  0                                                  (D)  None.

            

 

             g.   Choose the correct answer

                  

(A)     An entire array can be passed as an argument to a function.   

(B)  An array is passed to a function by value.

(C)  Any change done to an array, passed as an argument to function will be local to function only. 

(D) None of these.

 

             h.   Which is more appropriate for reading in a multi word string?

                  

(A)    gets( )                                          (B)  printf( )

(C)  scanf( )                                         (D)  puts( )

 

             i.    In  FILE *ptr; ptr is a pointer which

                                                                                                                                               

(A)   Points to another pointer FILE     

(B) A pointer to simple text files

(C)  Pointer to structure                            

(D) A pointer to integer denoting the start address of the file

                  

             j.    The invalid constant from the following

                                                                                               

(A)    +6.0E3                                        (B)  -5.5e-2

(C)  3.5e-5                                          (D)  1.5 e 4

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   Explain divide and conquer strategy                                                                   (8)

       

             b.   Write a program that reads a year and determine whether it is a leap year or not.                (8)

 

  Q.3     a.   Design an algorithm to evaluate the function sin(x) as defined by the infinite series expansion.

 

                   sin(x) = x/1!-x3/3!+x5/5!-x7/7!+……….   (8)

 

b.   Write an algorithm to compute the value of xn where n is a positive integer.                                           (8)

  Q.4     a.   Write short notes on

 

                   (i)   Compilation Errors (ii) Program efficiency (iii) Debugging                              (6)

                  

             b.   What is meant by function definition, function call and function declaration? Explain by giving an example.                                                           (6)

 

c.   Rewrite the following statement using if-else construct.

                   (i)    (x>50) ? (y=20) : (z=30);             (ii)    (d>20) ? (c=a+b) : (c=a-b);            (4)

       

 

 

 

  Q.5     a.   Write an algorithm to sort the numbers in ascending order using bubble sort.                       (8)

                                                                                                                                                

             b.   Write an algorithm to remove duplicates from an array.                                       (8)

       

  Q.6     a.  What is meant by array initialization and Explain the different types of array initializations for one-dimensional and two-dimensional array.                  (8)

            

             b.   Write a program to add rows and columns of a 3X3 matrix.                               (8)

       

  Q.7     a.   What is an algorithm? What are the features and characteristics of an algorithm.                  (6)

 

b.      Compare the use of nested if-else statement with the use of switch statement.                      (6)

 

              c.   What are escape sequences characters? List any 6 of them.                                (4)          

 

  Q.8     a.   Write recursive function to generate Fibonacci series.                                          (8)          

                  

b.      Explain Union with example.                                                                             (4)

 

             c.    Explain the declaration

(i)  float (*x[20])(int a);

                    (ii)  float (*x)(int *a[]);                                                                                       (4)

 

  Q.9     a.   What are the input and output functions used in file handling?                               (4)

 

             b.   Describe the output of the following

 

                   #include<stdio.h>                               

divide(int);

void main()

{

   int i=20;

   int val=divide(500)==50;

   printf(“\n %d”,val);

}

divide(int i)

{

   return(i/10);

}                                                                                                                       (6)

 

c.      Write a program using pointers to compute the sum of all elements stored in an array.                                                                                                    (6)