Code: DC-05                                                    Subject: PROBLEM SOLVING THROUGH ‘C’

Time: 3 Hours                                            June 2006                                                         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 << operator is used for  

 

                   (A)  Right shifting                                 (B)  Left shifting

(C)    Bitwise shifting                             (D)  Bitwise complement

       

b.      The C language includes the header file standard input & output in

 

(A)    stdlib.h library                               (B)  stdio.h library

(C)  conio.h library                              (D)  #include library

            

             c.   The value that follows the keyword CASE may only be

                  

(A)    constants                                      (B)  variable

(C)  number                                         (D)  semicolon

 

             d.   The statement which is used to terminate the control from the loop is

 

(A)    break                                          (B) continue

(C)  goto                                            (D) exit     

 

             e.   The machine registers are sometimes called

                  

(A)     local variables                              (B)  global variables

(C)  accumulators                                (D)  static variables

 

             f.    Set of values of the same type, which have a single name followed by an index is called

 

(A)     function                                        (B)  structure

(C)  array                                            (D)  union

 

             g.   An array of pointers is same as

 

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

(C)  pointer to function                         (D)  pointer to structure

 


             h.   What is the output of the following program segment?

                   main()

                   {

                   long i = 65536;

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

                   }

                 

(A)     0                                                 (B) 65536

(C)  -1                                                (D) 65

 

             i.    What is the output of the following program segment?

                   main()

                   {

                   int i = 1;

                   do

                   { printf(“%d..”, i);

                   } while(i--);

                   }

                  

(A)   0..1..                                            (B) 1..0..

(C) 0                                                   (D) -1

 

             j.    What is the output of the following program segment?

                   main()

                   {

                   int i = ++2;

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

                   }

 

(A)    3                                                  (B)  2        

(C)  0                                                  (D)  -1

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

  Q.2     a.   Explain divide & conquer strategy to solve any problem.                                     (4)

       

             b.   Explain the common programming errors.                                                           (6)

 

             c.   Write down steps, which are included in implementation of algorithms.                (6)          

 

  Q.3     a.   Design an algorithm for a given number n, compute n factorial (written as n!) where n  0.              (8)

 

             b.   Design an algorithm for the generation of the fibonacci sequence.                         (8)

 

  Q.4     a.   What is meant by identifiers?  How do identifiers differ from keywords?              (6)

                  

             b.   What are the bitwise logical operators?                                                               (4)

 


             c.   Explain the following statements:          

                   (i)  getchar()                                        (ii)  putchar()                                           (6)          

 

  Q.5     a.   Summarise the syntactic rules of the following loop statements?

                   (i)   for loop                                         (ii)  while loop

                   (iii) do-while loop                                                                                               (6)

       

             b.   What is meant by the conditional expression?                                                      (4)

 

             c.  Write a program to find the sum & average of the given numbers using the do----while loop.                                                                       (6)

 

  Q.6     a.   What is a function? List out the advantages & disadvantages of using functions in C?                       (4)

 

             b.   When passing parameters to functions, explain the difference between pass-by-value and pass-by-reference.                                                           (4)

 

             c.   Write a program to find the sum of given non-negative integers using a function declaration.

                   Sum = 1+2+3+4+-------n                                                                                 (8)

 

  Q.7     a.   What is an array & how is an array variable different from an ordinary variable?                  (4)   

 

             b.   Define an union which contains two members-colour which is an array of 12 characters and size which is int. Define two union variables and assign values to them.                                                    (4)

 

             c.   Write a program to read a set of lines from the keyboard & remove the white spaces such as tab, space, carriage return, new line, line feed & vertical tab from the text & display onto the screen.    (8)

            

  Q.8     a.   Distinguish between the following functions when operating on files:

 

(i)                  rewind and ftell

(ii)                printf and fprintf

(iii)               feof and ferror

(iv)              getc and putc                                                                             (8)

 

             b.   Write a program to copy the contents of one string to another string using a pointer method.                                                                       (8)

 

  Q.9     a.   What is meant by conditional compilation?                                                          (4)

 

             b.   What are the different functions involved in ctype.h?                                            (6)                      

                  

             c.   Write a program to read a set of values from the keyboard using a pointer structure operator & to display the contents of the structure onto the screen.                                                       (6)