DipIETE – CS (OLD SCHEME)

 

Code: DC05                                                     Subject: PROBLEM SOLVING THROUGH ‘C’

Flowchart: Alternate Process: JUNE 2009Time: 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 the best alternative in the following:                                 (2 10)

       

a.       The given code displays

                                                                                                                    float y = 7.5234;

                                                                                                                  printf (“%8.3f”, y);

 


                   (A)  7.523bbb                                     (B)  bbb7.523

(C)    bb7.5bbb                                    (D) None of the above

       

b.      The given code displays

   int a = 12;

   printf (“%d”, a);

 

(A)    12                                                (B)  8

                   (C)  80                                                (D)  14          

 

             c.   The “&&” is called as

                  

(A)    Relational operator                       (B)  Bitwise operator

(C)  Ternary operator                          (D)  Logical operator

 

             d.   In which header file is “getch” function available?

                                      

(A)    io.h                                             (B)  stdio.h

(C)  conio.h                                        (D)  stdlib.h

                                                               

             e.   The output of the following code is

                   for (x=1; x5;)

                       {

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

                        }

            

(A)     displays 1 infinite number of times

(B)     displays 1 to 5

(C)  displays 1 five times                     

(D)  none of the above

 

             f.    _______ is a memory location used by several variables of different datatypes

                  

(A)     Union                                           (B)  Array

(C)  Pointer                                         (D)  None of the above

 


             g.   The process of a function calling itself is called

                  

(A)     function recall                               (B)  pure function

(C)  recursion                                      (D) none of the above

 

             h.   The given code displays

                   main ( )

                   {

                    int a,b,c;

                   a=b=c=0;

                   a = ++b + ++c;

                   printf (“%d%d%d”, a,b,c);

                   }

                  

(A)    2 1 1                                            (B)  0 1 1

(C)  1 2 2                                            (D)  0 0 0

 

             i.    The output of the following code is

                   main ()

                   {

                      int x,y;

                      int *ptr;

                      x = 10;

                      ptr = &x;

                      y = ++*ptr;

                      printf(“%d%d”, x,y);

                   }

                                                                                                           

(A)   10 10                                           (B) 11 11

(C)  10 11                                           (D) 11 10

                  

             j.    The value of the x will be

                   i = 7;

                   x = ++i;

                   x = i++;

 

(A)    9                                                  (B)  7

(C)  8                                                  (D)  10

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   Design an algorithm to convert a decimal integer to its corresponding octal representation.              (8)

       

             b.   Explain the various stages involved in program design.                                         (8)

 

  Q.3     a.   What are the different categories of operators available in C?  Explain each operator with an example.                                                                   (8)

 

b.    Write a C program to find the largest value from a set of n numbers where

                                                                 n is an user input.                                                    (8)

 

 

  Q.4     a.   Explain the working of switch statement with an example.  How does it differ from “if – else” construct?                                                                 (8)

                  

             b.   Write a C program to find whether a given number is palindrome or not.             (8)

       

  Q.5     a.   Explain different storage classes in C.   (7)

                                                                                                                                                

             b.   Write a C program to add two matrices using function.                                       (9)

       

  Q.6     a.  Differentiate ‘array of pointers’ and ‘pointer to the array’ with example.              (8)

            

             b.   Write a C program to remove duplicates from an array.                                      (8)

       

  Q.7     a.   Explain the following random access file functions:-

 

                   (i)    fseek()                                         (ii)  lseek()

                   (iii)  ftell()                                             (iv) rewind()                                            (8)

 

b.      Write a C program to find the nth Fibonacci number.                                           (8)

 

  Q.8     a.   Write a function that returns 1 if its argument is a prime number and returns zero otherwise.                                                                        (8)                                                             

                  

b.      What is a structure?  How it is different from array?  Construct a structure “student” including necessary details and show how it can be instantiated.                                                        (8)

 

  Q.9     a.   List five common programming mistakes.  What is the difference between Run-time errors and logical errors?                                                                                                                         (8)

 

             b.   Write a complete programme for doing Binary search.                                        (8)