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

Time: 3 Hours                                                      Flowchart: Alternate Process: December 2005                                                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.       ‘C’ is often called a  

 

                   (A)  Object oriented language              (B)  High level language

(C)    Assembly language                      (D)  Machine level language

       

b.      The loop in which the statements within the loop are executed at least once is called

 

(A)    do-while                                       (B)  while

(C)  for                                                (D)  goto

            

             c.   The control automatically passes to the first statement after the loop in

                  

(A)    continue statement                        (B)  break statement

(C)  switch statement                           (D)  if  statement

 

             d.   A self contained block of statements that perform a coherent task of some kind is called a

 

(A)    Monitor                                      (B) Function

(C)  Program                                      (D) Structure         

 

             e.   Recursion is sometimes called

                  

(A)     Circular definition                         (B)  Complex definition

(C)  Procedure                                    (D)  Union

 

             f.    Unsigned integer occupies

 

(A)     Two bytes                                    (B)  Four bytes

(C)  One byte                                      (D)  Eight bytes

 

             g.   Each C preprocessor directive begins with

 

(A)     #                                                  (B)  include

(C)  main()                                          (D)  {

 


             h.   main() {

                   long i = 30000;

                   printf(“%d”, i); }

                 

                  the output is

 

(A)    3000                                            (B) 30000

(C)  0                                                  (D) -1

 

             i.    The directive that can be used to test whether an expression evaluates to a nonzero value or not is

                  

(A)   #if                                                (B) #elif

(C) #endif                                            (D) #exit

 

             j.    main() {

                   printf(“%p\n”, main());

                   }

 

(A)    Prints the address of main function.

(B)    Prints 0.                                      

(C)    Is an error.

(D)    Is an infinite loop.

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

  Q.2     a.   What is top down design?  Write down the steps to breakdown a problem into sub problems?                                                                  (8)

       

             b.   What are the qualities and capabilities of good algorithms?                                  (8)

 

  Q.3     a.   Design an algorithm that accepts a positive integer and reverses the order of its digits.                     (8)

 

             b.   Given a set of n numbers design an algorithm that adds these numbers and returns the resultant sum.                                                                       (8)

 

  Q.4     a.   Determine the hierarchy of operations and evaluate the following expression:

                   kk = 3 / 2 * 4 + 3 / 8 + 3                                                                                   (4)

 

             b.   While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000.  If the quantity and price per item are input through keyboard, write a program to calculate the total expenses.                                                            (6)

 

             c.   Write a program to copy input to output, replacing each string of one or more blanks by a single blank.                                                                  (6)                                                             

 

 

 

 

 

  Q.5     a.   How many types of logical operators are there in ‘C’ programming language.                      (4)

       

             b.   Why do we use functions?  Give the advance features of functions.                      (4)

 

             c.  Write a program to test if a character from the keyboard is a lower case letter.                     (8)

 

  Q.6     a.   What are the features of C preprocessor?  Give the differences between macros and functions?                                                                 (6)

 

             b.   Write a function, which takes an array of real numbers and its size as arguments and returns the maximum. Using the above function write a program to read a set of real numbers from the keyboard and find the maximum number in the array.                                                                         (10)

 

  Q.7     a.   Define a pointer?  Write a program to assign any number at random to an integer variable k and display the same through pointer.                           (8)   

 

             b.   Write a program to read the coordinates of the end points of a line and to find its length.  Use a structure variable named ‘line’ to store the relevant information about its end points.                          (8)

            

  Q.8     a.   Explain library string functions.  Write a program to copy the contents of the string “HELLO” to another string.                                                  (8)

 

             b.   Explain the following types of errors, which are considered while testing programs.

i)                    Syntax errors.

ii)                   Run-time errors.

iii)                 Logical errors.

iv)                 Latent errors.                                                     (8)

 

  Q.9     a.   Define the functions:                            

 

                   (i) fwrite()                                            (ii) fread()                                               (6)

 

             b.   Give the difference between sprintf() and sscanf() functions.                                (6)                      

                  

             c.   What are static and dynamic tools?                                                                     (4)