Flowchart: Alternate Process: DECEMBER 2007
Code: DC05                                                     Subject: PROBLEM 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.       If a = 5 and b = 7 then the statement p = (a > b) : a ? b

 

                   (A)  assigns a value 5 to p                    (B)  assigns a value 7 to p

(C)    assigns a value 8 to p                   (D) gives an error message

       

b.      The expression P >> 6 shifts all bits of P six places to right.  What is the value of P >> 6 if

 

(A)                                          (B) 

                   (C)                                       (D)                 

 

             c.   If an integer occupies 4 bytes and a character occupies 1 bytes of memory, each element of the following structure would occupy how many bytes?

                   struct name

                         {

                         int age;

                         char name [20];

                         }                                                                    

 

(A)    5                                                  (B)  24

(C) 21                                                 (D)  22

 

             d.   If an array is used as function argument, the array is passed

                                      

(A)    by value.                                     (B)  by reference

(C)  by name.                                     (D)  the array cannot be used as a

                                                                  function argument.

 

             e.   To access a structure element using a pointer, ___________ operator is used

                  

(A)     dot (.)                                          (B)  pointer (&)

(C)  pointer (*)                                    (D)  arrow ()

 

             f.    The library function sqrt( ) operates on a double precision argument.  If, i is an integer variable, which one of the following calls would correctly compute sqrt(i)?

                  

(A)     sqrt((double)i)                              (B)  (double) sqrt(i)

(C)  (double) (sqrt(i))                           (D)  sqrt(i)

 


             g.   What will happen if the following loop is executed?

                   int num = 0;

                   do

                   {

                           --num;

                           printf(“%d”, num);

                           num++;

                           }while (num >= 0);

                   }

 

(A)     The loop will run infinite number of times.       

(B)     The program will not enter the loop.

(C)     There will be a compilation error. 

(D)    There will be runtime error.

 

             h.   The break statement causes an exit

                  

(A)    Only from the innermost loop.      

(B)    Only from the innermost switch.

(C)    From the innermost loop or switch.    

(D)    From the program.

 

             i.    It is necessary to declare the type of function in the calling program if

                                                                                               

(A)   Function returns an integer.

(B)   Function returns a non-integer value.

(C)   Function is not defined in the same file.

(D)   Function is called number of times.

                  

             j.    The function fprintf is used in a program

 

(A)    When too many printf calls have been already used in the program.                           

(B)    In place of printf, since printf uses more memory.

(C)    When the output is to be printed on to a file.  

(D)    When the type of variables to be printed are not known before.

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   Differentiate between a compiler and an interpreter.                                            (4)

       

             b.   Explain the main factors that should be kept in mind for the implementation of an algorithm that is designed in a top down fashion.                             (8)

                         

             c.   Name and explain the primitive or fundamental data types that Compilers support.              (4)

 

  Q.3     a.   Write an algorithm to find the sum of the squares of the first n positive integers.

                                                                                 (8)

 

b.    Write an algorithm to find the value of  where n is a positive integer

                                                                 greater than 1.                                                        (8)

  Q.4     a.   Write an algorithm to find the highest common factor of two positive numbers.                    (8)

                  

             b.   Name two types of program testing and explain them in detail.                            (8)

       

  Q.5     a.   Explain the following operators with the help of examples

                   (i)   Conditional operator.                     (ii)  sizeof operator.

                   (iii) Increment operator.                       (iv) Cast operator.                           (4  3)

            

             b.   Write a program to convert the given temperature in Fahrenheit to temperature in Celsius where cel = ((fah – 32) * 5/9); and Fahrenheit is denoted by fah.                                                                     (4)

       

  Q.6     a.  Write a program to display the real, imaginary and equal roots of a quadratic equation .                                                               (8)

            

             b.   What do you mean by a loop?  Explain the difference between the do loop,  while loop, and for loop  with the help of an example.                        (8)

       

  Q.7     a.   How are values initialized in one – dimensional array?  Should the entire array be initialised in the definition?                                                                                                                         (4)

 

b.      Write a program to find the average of 10 real numbers in an array.                     (4)

 

c.   Write a C program to read two matrices and display their sum.                           (8)

 

  Q.8     a.   Name and explain two ways of passing arguments to a function.                          (4)          

                  

b.      Write a function “power” that computes x raised to the power y, where x and y are integers and the function returns a double-type value.                 (4)

 

c.    Write a program to find the maximum of 10 numbers stored in an array with the help of user defined functions.                                            (8)

                  

  Q.9     a.   Define a structure for a student having name, roll number and marks obtained in six subjects.  Write a program to input the details for 20 students and print the details of the students who have scored more than 70% marks overall.                                                                                          (12)

 

             b.   If p is a pointer to an address and j is a numeric value, than what does the expression like p + j mean.                                                                    (2)

 

             c.    List the four stages involved in program design.                                                  (2)