AMIETE – CS/IT (OLD SCHEME)

 

Code: AC05 / AT05                                                  Subject: PROGRAMMING & PROBLEM

Flowchart: Alternate Process: DECEMBER 2009                                                                                                              SOLVING THROUGH ‘C’

Time: 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:                                (2  10)

       

             a.   “int (*p)[10]” code indicates:

 

(A)     array of integer pointers                (B)  integer pointer to array

                   (C)  integer pointer                              (D)  none of above

 

             b.   Minimum number of temporary variables required to swap the contents of two integer variables are

 

(A)  two                                              (B)  three

                   (C)  one                                              (D)  zero

 

c.       The output of the following code will be:

 

#define one 0
#ifdef one
          printf("one is defined ");
#ifndef one
          printf("one is not defined ");

 

(A)  one is defined                               (B)  one is not defined

                   (C)  undefined                                     (D)  will generate a compiler error

       

d.      void main()
{
        float j;
        j=1000*1000;
        printf("%f",j);
}

 

(A)    1000000                                      (B) Overflow

(C) Error                                             (D) None

            

 


e.    void main()
{
           int i=7;
           printf("%d",i++*i++);

                                                                 }

                                                                 Output of above code is:

       

(A)    56                                                (B) 49

(C)  64                                                (D) 72

 

             f.    void main()
{
         static int i=3;
         printf("%d",i--);
         if (i > 0)

                              main();
}

 

(A)    3 2 1                                           (B)  3 3 3

(C)  3 0 0                                           (D)  2 1 0

 

             g.   void main()
{
           int x=5;
           printf("%d %d %d\n",x,x<<2,x>>2);
}

 

(A)  5, 25, 5                                       (B) 5, 20, 1

(C)  5, 2, 4                                         (D) none of above

 

h.    do……..while loop is

 

(A)     definite repetition loop                  (B)  exit-controlled loop    

(C) entry-controlled loop                     (D)  nested loop

 

             i.    For allocating multiple blocks of storage, the function used is   

                   (A)  malloc()                                        (B)  calloc()

(C)    realloc()                                       (D)  not possible

 

             j.    The following data structure will reserve ______ bytes

            

                   union {

                                    char n[4];

                                    int a,b;

                                      long int c;};

            

                   (A)  4                                                  (B)  12

(C)  does not occupy any memory       (D)  none of above


 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   Explain the complete compilation process. Show with diagram, how a source program (.c program) is executed. Mention all the system program used in the process.                                           (10)     

       

             b.   Write a program to generate all the prime numbers in the given range of numbers. Thus, the input of the program will be two numbers specifying the range and output will be all the prime number within that range, if any. It should output “NO prime numbers” if there are no such numbers in the range.                      (6)

 

  Q.3     a.   Explain the term complexity and its types. Explain “Big-oh notation O” with example.                      (6)       

 

b.      Write a program to sort an array of elements in ascending order using pointer.                    (10)

 

  Q.4     a.   Explain the fseek() , frewind(), ftell ()and fscanf()                                                (4)

            

             b.    Write a program to perform the summation of the series:

                    1/2! + 3/4! + 5/6! + ...                                                                                      (4)

 

c.       Write a programme to generate the following as output up to n rows, where n is a user input

 

                                                                 1                                                                            (8)

                                                      0     1

                                                      1     0     1

                                                      0     1     0     1

                                                      1     0     1     0     1

                                                          .      .     .    

                                                     

                                                      up to n rows                                                                       

       

Q.5       Do as directed: (Any TWO)

 

                   (i)   Write a program to create a linked list storing an integer value in each node.

                   (ii)  Write a program to copy one file to another where all 'a' in the previous file is replaced by 'z'

                   (iii)  Explain Dynamic Memory allocation. Also explain all the functions provided for dynamic memory allocation i.e. malloc(), calloc(), realloc(), free(). State how it is better than static memory allocation.                     (16)

                  


       

  Q.6     a.   p is a two dimensional array. Explain the meaning of the following expressions.

 

(i)         p+i

(ii)        * (pi)

(iii)      * (p+i)+j

(iv)      * (*(p+i)+j)                                                                                               (4)

 

             b.   What is meant by “scope of a variable”? Explain the local, global and extern scope of variable.                                                                  (4)

 

             c.   Write a program to replace a given sub-string with the specified sub-string.             

            e.g.       Input string: “best of luck”

                                    replace 'of' with 'the'

                                   Output string:  “best the luck”                                                             (8)          

 

  Q.7     a.   Write a program to find the sum of the diagonal elements of a square matrix.                       (6)

 

            b.   Write a program to lexically (alphabetically ascending) sort the number of strings provided. Use pointers.                                                               (10)

 

  Q.8     a.   Explain the concept of testing the program. What is meant by “basic path testing” and “black box testing” with an example?                                 (8)

 

             b.   What is the difference between while and do-while construct?  Explain the case where do-while can be used.                                                                                                                         (4)

 

             c.   Write a program to print the reverse of an integer number.  Do not print the reverse digit by digit.                                                               (4)

 

  Q.9     a.   A record consists of Name and Roll number of student. Write a program to store records of n students and display the output in tabular format.      (8)

 

b.   Write a program to remove the duplicates from sorted array.                              (8)