Code: AC05 / AT05                                                  Subject: PROGRAMMING & PROBLEM

Flowchart: Alternate Process: DECEMBER 2008                                                                                                              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 best alternative in the following:                                         (2x10)

                

             a.   The variables declared out of the main() function are

 

(A)     External variable                           (B)  Register variable

                   (C)  Auto variable                                (D)  Static variable

 

             b.   The value of the given expression is

                              x + y * x z     where x = 5,  y = 6, and z = 8

 

(A)  47                                                (B)  33

                   (C)  –33                                              (D)  27

                  

 

c.       Which is invalid identifier name?

 

(A)  my_name                                     (B)  Part_123

                   (C)  part123                                        (D)  123part

       

d.      The output of given code is

                                                                           for (i = 1; i <=10; i++);

                                                                           printf (“%d”, i);                                            

 

(A)    1 2 3 4 5 6 7 8 9 10                     (B) 10

(C) infinite loop                                    (D) None of the above.

            

e.    What is the output

                              a = 5;

                              a<<1;

0

1

0

 

 

1

0

0

 

 
 


(A)   

0

0

1

 

 

1

0

1

 

 
                                                    (B) 

(C)                                                      (D) 

 

             f.    The value of given code is

                              floor(–1.02);

 

(A)    2.0                                              (B)  –1.0

(C)  –2.0                                            (D)  1.0    

 

 

g.       What is the output of following program:-

                                 main( )

                                 {

                                             int x, *p, **q;

                                             x = 10;

                                             p = &x;

                                             q = &p;

                                             printf(“Value of x = %d”, **q);

                                 }

 

(A)     Value of x = 10                           

(B)  Value of x = 1203 (address of q)

(C)  Value of x = 2034 (address of p) 

(D)  None of the above

 

             h.   The name of the standard errors file is

 

(A)  stderror                                       (B) stdr

(C)  stderr                                          (D) none of the above

 

             i.    Minimum number of temporary variables needed to swap the contents of two variables is/are

 

                   (A)  1                                                  (B)  2

(C)    3                                                 (D)  0

 

             j.    Name the datastructure which has two pointer elements: One pointing to the next element and another pointer pointing to the previous element with which one can traverse the list in either direction.

 

                   (A)  Stack                                           (B)  Queue

(C)  Linked list                                    (D)  Double linked list

 

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

 

  Q.2     a.   Discuss general problem solving strategies.                                                         (8)          

       

             b.   What is the O-notation?  Discuss what the terms “worst case” and “average case” behaviour of algorithm mean?                                                                                                               (8)

 

 

  Q.3     a.   Explain the various criteria for designing efficient algorithm.                                  (7)          

 

b.      Design an algorithm to find the maximum number in an array of numbers.             (9)

 

 

  Q.4     a.   Compare switch statement with if-else statement?  Outline the situations in which each one is preferred.                                                                  (7)

                          

             b.    Write a C program to sum the digits of a number using a while loop.                   (9)

       

  Q.5     a.   What is meant by array initialization and what types of storage class be used for array initialization.              (7)

                                                                                        

             b.   Write a C program to find the given string as palindrome or not.                          (9)

 

 

  Q.6     a.   What is meant by function arguments, function call and return values.                   (6)

 

             b.   Write a C program to perform addition, subtraction, multiplication and division of two complex numbers using a structure.                                  (10)

 

 

  Q.7     a.   Distinguish between the array of pointers and pointer to the array.                       (7)

 

b.   Write a C program to construct a linear linked list of n numbers and to display the list in Last In First Out (LIFO) method.                                  (9)

 

 

  Q.8     a.   Explain the following functions:

                   (i)  feof( )                                             (ii) ftell()

                   (iii) fseek()                                           (iv) ferror()

                   (v)  malloc()                                                                                                     (10)

 

             b.   Why is a linked list called dynamic data structure?  What are the advantages of using linked list over arrays?                                                           (6)

 

 

  Q.9     a.   What is a preprocessor directive?  Write a macro to compute the cube of a number.                       (5)

 

b.    Distinguish between #ifdef and #if directives.                                                      (5)

 

c.    Explain Testing and debugging process briefly.                                                   (6)