Code: DC05                                                     Subject: PROBLEM SOLVING THROUGH ‘C’

Flowchart: Alternate Process: DECEMBER 2008Time: 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 operators <<  and   >>   are

                                                                                                                                                      

                   (A)  assignment operator                      (B)  relational operator

(C)    logical operator                            (D) bitwise shift operator

       

b.      Which of the following numerical value is invalid constant

  

(A)    .75                                               (B)  9.3e2

                   (C)  27,512                                         (D)  123456              

 

             c.   A C program contains the following declaration int i=8, j=5 what would be the value of following expression?

                             abs(i-2*j)

 

(A)    2                                                  (B)  4

(C)  6                                                  (D)  8

 

             d.   What will be the output of the following program

                  main( )

{

                              int k,  num=30;

                              k=(num>5 ? (num<= 10 ? 100:200):500);

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

                                   }

                                      

(A)    100                                             (B)  5

(C)  30                                               (D)  500

                                                               

             e.   What is the output of the following code

                        int n = 0, m=1;

                                    do

                                    {

                                    printf(“%d”, m);

                                    m++;

                                    }

                                 while(m<=n);                        

            

(A)     0                                                  (B)  2

(C)  1                                                  (D)  4

 


             f.    If a=8 and b=15 then the statement

                          x= (a>b) ? a:b;

                  

(A)     assigns a value 8 to x                    (B)  gives an error message

(C)  assigns a value 15 to x                  (D)  assigns a value 7 to x

 

             g.   What is the output of the following code

                                    int n=0, m;

                                                for (m=1;  m<=n+1;  m++)

                                                printf(“%d”, m);

                  

(A)     2                                                  (B)  1

(C)  0                                                  (D) 6

 

             h.   How many times the following loop be executed

                                    {

                                    …

                                    ch = ‘b’;

                                    while(ch >= ‘a’ && ch <= ‘z’)

                                             ch++;

                                    }

                  

(A)    0                                                  (B)  25

(C)  26                                                (D)  1

 

             i.    Which of the following is FALSE in C

                                                                                                                                                                                                                                                                            

(A)   Keywords can be used as variable names      

(B)   Variable names can contain a digit

(C)  Variable names do not contain a blank space 

(D)  Capital letters can be used in variable names

                  

             j.    int **ptr;  is

                  

(A)    Invalid declaration                        (B)  Pointer to pointer

(C)  Pointer to integer                          (D)  none of the above

 

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   Explain the top-down technique for algorithm design.                                          (8)

       

             b.   Write an algorithm to reverse the digits of an integer.                                           (8)

 

  Q.3     a.   Explain the following statements

                   (i)    for loop

                   (ii)   while loop

                   (iii)  do-while loop                                                                                              (8)

 

b.   Write an algorithm to generate prime numbers in the first n positive integers.                        (8)

 

  Q.4     a.   Write an algorithm to find the square root of a number.                                       (8)

                  

             b.   Write a program to find the sum of odd and even numbers between 1 and 100.                  (8)

       

  Q.5     a.   Define pointers and discuss the advantages & disadvantages of pointers.             (6)

                                                                                                                                                

             b.   Write a program to swap two elements using pointer concept.                             (6)

 

c.       Classify the different types of programming errors.                                              (4)

       

  Q.6     a.  What are the input and output functions used with the files.                                  (4)

            

             b.   Write a menu driven program to find perimeter of rectangle, circle, square, triangle.             (8)

 

             c.   Differentiate between Structure and Array.                                                         (4)

       

  Q.7     a.   Define a function? Explain Call by value and Call by reference.                            (8)          

                    

b.      Write a program to accept the elements of the structure

(i) emp_no                                           (ii) basic_pay

and display the same structure along with the DA, CCA and  gross salary. DA and CCA are calculated as follows        

       DA = 51% of basic_pay 

       CCA = Rs.100/- consolidated                                                                    (8)

 

  Q.8     a.   Explain the following operators

                   (i)    Arithmetic Operator                     (ii)  Relational Operator

                   (iii)  Logical Operator                          (iv) Increment & Decrement Operator

                   (v)   Conditional Operator                                                                                (10)          

                  

b.      Write a program to subtract two matrices.                                                          (6)

 

  Q.9     a.   Write a C function to find the maximum number in a set of n numbers.                 (6)

 

             b.   Write a C program to find the sum of digits of a number using recursion.              (8)

 

c.       Determine the value of the following expression

(i)                  x=a-b/3+c*2-1           a=15, b=12, c=3

(ii)                z=2*x/(3*y)                x=8.8, y=3.5                                          (2)