Code: DC-05                                                    Subject: PROBLEM SOLVING THROUGH ‘C’ Flowchart: Alternate Process: JUNE 2007

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 A. 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 A.   Choose the correct or best alternative in the following:                                         (2x10)

       

a.       Determine which of the following is a valid character constant

                   (A)  ‘\\’                                               (B)  ‘\0’

(C)    ‘xyz’                                            (D)  ‘\052’

          

b.      The maximum value that an integer constant can have is

(A)    .32767                                         (B)  32767

                   (C)  1.7014e+38                                 (D)  –1.7014e+38     

 

             c.   The expression X=4+2%-8 evaluates                            

(A)     –6                                               (B)  6

(C)   4                                                 (D)  None

 

             d.   What will be the output of following program?

                   main()

                   {

                           int x=15;

                           printf(“\n%d%d%d”, x!=15, x=20, x<30);

                   }

(A)    0, 20, 1                                       (B)  15, 20, 30

(C)  0, 0, 0                                         (D)  Error

 

             e.   How many times the following program would print (“abc”)?

                   main()

                   {

                           printf(“\nabc”);

                           main();                                              

                   }     

(A)     Infinite number of times                 (B)  32767 times

(C)  65535 times                                 (D)  Till the stack does not overflow

 

             f.    What would be output of the following program?

                   # define SQR(X) (X*X)

                   main()

                   {

                           int a, b=3;

                           a = SQR(b+2);

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

                   }

(A)     25                                                (B)  11

(C)  Error                                            (D)  Garbage value

             g.   What would be output of the following program?

                   #include "stdio.h"

                   main()

                   {

                           printf(“%d%d”, size of (NULL!), size of (“ “));

                   }

(A)     2  1                                              (B)  1  2

(C)  2  2                                              (D)  1  1

 

             h.   What would be output of the following program, if the array begins at 65486?

                   main()

                   {

                           int arr[ ] = {12, 14, 15, 23, 45};

                           printf(“%u%u”, arr+1, &arr+1);

                   }

(A)    65486, 65486                              (B)  65488, 65488

(C)  65488, 65496                              (D)  None of the above

 

             i.    Given the statement,  maruti.engine.bolts=25;

                   which of the following is true?                               

(A)   Structure bolts is nested within structure engine

(B)   Structure engine is nested within structure maruti

(C)   Structure maruti is nested within structure engine

(D)   Structure maruti nested within structure bolts

                  

             j.    Which amongst the following is not a keyword?

                   (A)  external                                        (B)  int

                   (C)  float                                             (D)  double

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

  Q.2     a.   Which programming design approach is followed by ‘C’ language (TOP-DOWN/BOTTOM-UP). Justify.                                                            (3)

       

             b.   Evaluate the following expression. Show the hierarchy displaying all steps during evaluation

                   (i)    int i = 2*3/4+4/4+8–2+5/8

                   (ii)   int k = 3/2*4+3/8+3

                   (iii)  float s = q*a/4–6/2+2/3*6/g (q = 4, a=2, g=2);                                           (6)

 

                           c.   What is the difference between Testing & Debugging? Explain different Debugging Techniques.                                                                  (7)

 

  Q.3     a.   Enumerate the steps that need to be taken to design efficient algorithms.              (6)

 

b.    Replace the if-else statements by conditional operators

                 main( )

                 {

                        int code;

                        scanf("%d", &code);

                        if(code>1)

                                                                 printf(“\nJerusalem”);

                        else

                                                                 if(code<1)

                                                                 printf(“\nEddie”);

                                else

                                                                 printf(“\nC Brain”);

                 }            

                                                                                                             (6)

             c.   Write a program to determine whether a given number is an Armstrong number or not. (Hint: 13+53+33 = 153)                                                    (4)                                                             

 

  Q.4     a.   Compare in terms of their functionality, following pair of statements

                   (i) while and Do...while

                   (ii) Break and Continue                                                                                      (5)

                  

             b.   Write ‘switch’ statement that will examine the value of an integer variable flag & print one of the following messages:

                   (i)  HOT, if flag=1                               

                   (ii) LUKE WARM, if flag=2

                   (iii) COLD, if flag=3                           

                   (iv) OUT OF RANGE, if any other value                                                           (5)

 

             c.   What does ‘return’ statement do in a function? Can a function have more than one return statement? Explain. Write the user-defined code for finding factorial( ) of a given number using Recursion.         (6)

 

  Q.5     a.   Define an array. Write a program for 2-D Matrix Multiplication using arrays.                      (8)

            

             b.   Write an algorithm to find greatest common divisor of two positive non-zero integers.                      (5)

       

             c.   Point out and rectify the error(s), if any in the following code:

                 main( )

                 {

                        int code, flag;

                        if(code = = 1 & flag = = 0)

                                                                 printf(“/n The Eagle has landed);

                 }                                                                                                                            (3)

 

  Q.6     a.   What would be the output of following code?                                                      (4)

 

                 main( )

                 {

                        float a=13.5;

                        float *b, *c;

                        b =&a; // suppose the address of ‘a’ is 1006.

                        c = b;

                        printf(“\n%u%u%u”, &a, b, c);

                        printf(“\n%f %f%f%f%f”, a, *(&a), *&a, *b, *c);

                 }                                                                                                                

 

             b.   Write at least any 2 differences between malloc( ) & calloc( ) function.               (4)

 

             c.   What are the advantages of using pointers.                                                          (4)

 

             d.   Differentiate between call by reference and call by value. Use suitable examples to explain.             (4)

 

  Q.7     a.   Write macro definition for the following:

                   (i)  Minimum of 2 values; MIN (a, b)

                   (ii) To check whether entered character is a digit (or) not; ISDIGIT(Y)               (6)   

 

b.      Write different built-in (library) functions provided by ‘C’ language for handling I/O operations on files.                                                                  (10)

 

  Q.8     a.   What would be output of following code?                                                              

                   Justify your answer

                   (i)  f1( )

                            {

                                     Static int count= 5;

                                     printf(“\n count=%d”, count– –);

                                     if(count != 0)

                                     f1( );

                            }

 

(ii)          int i=0;

         main( )

                            {

                                     printf(“\main’s i=%d”, i);

                                     i++;

                                     val( );

                            }      

                            val( )

                            {

                                     i=100;

                                     printf(“\n val’s i=%d”, i);

                                     i++;

                            }

b.      What is Program Testing? What are the kinds of errors that cannot be detected by compiler. List and explain the stages of a testing process.             (6)

 

c.    Write a C function using pointers to exchange the values stored in two memory locations in the memory.                                                               (6)

                  

  Q.9     a.   What are the different types of errors that can occur during I/O operations on a file?                       (6)

 

             b.   Write user-defined function for copying a string to another                                  (6)

 

             c.    With the help of examples explain the purpose of Typedef declaration                (4)