AMIETE – CS/IT (OLD SCHEME)

 

Code: AC05 / AT05                                                  Subject: PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’                                    Flowchart: Alternate Process: JUNE 2009                                      

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 the best alternative in the following:                                  (210)

                

             a.   Short int holds the data size of _____ bits long.

 

(A)     32 bits                                         (B)  8 bits

                   (C)  16 bits                                          (D)  4 bits

 

             b.   The output of the following is

                      sum = 0;

                      i = 1;

                      while(i <= 10)

                         sum += i++;

                         printf(“%d”, i);

 

(A)  10                                                (B)  11

                   (C)  1                                                  (D)  None of the above

                  

 

c.       The mode used in file processing to create a binary file for read/write is

 

(A)  “w+b”.                                         (B)  “rw+b”.

                   (C)  “rwb”.                                          (D)  “wb”.

       

d.      Only _______ arithmetic operations can be used on pointers.

 

 

(A)    One                                             (B) Two

(C)  Three                                           (D) Four

            

e.    The output of the following is

                              printf(“%f\n”, ceil(9.9));

 

 

(A)    9.9                                               (B)  9.0

(C) 10                                                 (D)  10.000000


 

             f.    What is the output?

    main()  {

    int x, a, b;

    a=4;

    b = 5;

          x = a&b;

                                                                           printf (“%d”, x);

                                                                           }                                                                                         

 

(A)    5                                                       (B)  4

(C)  2                                                 (D)  1       

 

             g.   Each C preprocessor directive begins with

 

(A)  #                                                 (B) include

(C)  main()                                          (D) {

 

 

h.    What is the output of following program:-

                                 main( )

                                 {

                                             int x, y;

                                             int *ptr;

                                             x = 10;

                                             ptr = &x; y = ++*ptr;

                                             printf(“Value of y = %d and pointer = %d\n”, y, *ptr);

                                 }

 

(A)     Value of y = 10 and pointer = 10 

(B)  Value of y = 11 and pointer = 11

(C)  Value of y = 11 and pointer = 10 

(D)  Value of y = 10 and pointer = 11

 

             i.    The function used to read a set of alphanumeric characters from stdin until carriage return key is pressed and places a NULL in memory and returns is

 

                   (A)  gets()                                           (B)  getch()

(C)    getchar()                                      (D)  None of the above

 

             j.    The ________ is used to return the current position of the character pointer in the given file.

 

                   (A)  ftell()                                            (B)  lseek()

(C)  fflush( )                                         (D)  fseek( )

 


 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

 

  Q.2     a.   Explain the various approaches to program design.                                             (8)          

       

             b.   Explain the computational complexity of an algorithm.                                         (8)

 

  Q.3     a.   Design an algorithm to compute the value of xn when n is a positive integer considerably greater than 1.                                                                  (8)                                                             

 

b.      Write a program in C to compute the sum of the digits of a given integer number.                (8)

 

 

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

                   (i)    While and For                              (ii)   Break and Continue

                   Use suitable examples.                                                                                       (6)

                          

             b.    Write a recursive C program to generate fibonacci series upto n terms.             (10)

       

  Q.5     a.   Distinguish between

                   (i)   Character array and Strings.

                   (ii)  Call by value and Call by reference.                                                             (8)

                                                                                        

             b.   Write a C program to search for a number in a given list of numbers.  Use binary search technique.                                                                        (8)

 

  Q.6     a.   What is meant by the register variable? What is the scope of it? How is a register variable different from an automatic variable.                               (6)

 

             b.   Write a C program to reverse a character string using pointers.                         (10)

 

  Q.7     a.   What is a linked list?  What are the advantages and disadvantages of using a linked list?  Explain in brief the different types of linked list.                  (8)

 

b.   Write a C function to insert a node at a specified position in a linked list.            (8)

 

  Q.8     a.   Explain the merits and demerits of the random access file processing in C.           (6)

 

             b.   Write a C program to read a string from the keyboard and to store them onto the given file and again to read from the file and to display the contents of the file using fgets() and fputs() function. (10)

 

  Q.9     a.   What is conditional compilation? How does it help a programmer?                      (6)

 

b.   What are preprocesser directives?  What is the syntax to specify preprocessor directive?  Name the different categories of preprocesser directives.                                                                 (4)

 

c.    Explain the types of errors that are likely to be present in a program.                  (6)