Tuesday, November 16, 2010

Fundamentals of Programming FOP


Gujarat University

MCA Semester I
FOP

Date: 18-1-2001                                                                                                                                 Marks:50


Instructions:
1.      Answer both the sections in separate answer books.
2.      Make necessary assumptions wherever necessary.

Section I


Q-1 a) What do you understand by Operator precedence and associatively? Explain giving suitable examples.
                                                                                                                                                                        (4+5)
       b) A ‘C’ program contains the following statements:
            #include <stdio.h>
            int I;
            long ix;
            unsigned u;
            float x;
            double dx;
Write an appropriate printf function to write out the values of I, ix, u, x and dx, assuming that each integer quantity will have a minimum filed width of five characters, the long integer will have a minimum filed width of 12 characters, and the floating point quantity will be atleast 10 characters with a maximum of five decimal places.

Q-2      Answer any two:                                                                                                                                 (8)
a)      Given a list of marks ranging from 0 to 100, write a C program to compute and print the number of
Students.
i)                    Who have obtained more than 80 marks.
ii)                  Who have obtained more than 60 marks.
iii)                Who have obtained more than 40 marks.
iv)                Who have obtained 40 or less marks
v)                  Who have obtained marks in the range 81 to 100
vi)                Who have obtained marks in the range 61 to 80
vii)              Who have obtained marks in the range 0 to 40.
The program should use minimum number of If statements.
b)      Write a ’C’ program to generate first N prime numbers.
c)      Write a ‘C’ program to sort a list of characters.

Q-3 a) State several advantages to use of functions.                                                                          (3+2+3)
       b) Each of the following is the first line of the function definition. Explain the meaning of each.
            i) float f(float a, float b)          ii) void f(int a)
            iii) long f (long a)                    iv) char f(void)
       c) What do you understand by scope and lifetime of a variable? Describe giving suitable examples.

OR

Q-3 a) What is pointer? How pointers can be used to achieve the effect of call by reference parameter passing
mechanism.                                                                                                                             (3 + 4+1)
       b) A ‘C’ program contains the following declaration:
            Static int x[8] = {10, 20, 30, 40, 50, 60, 70, 80};
i)                    what is the meaning of x?
ii)                  what is the meaning of (x+2)?
iii)                What is the value of (*x+2)?
iv)                What is the value of *(x+2)?
      c) Distinguish between (*m) [5] and *m[5].


Section II


Q-4      Define the following giving suitable examples:                                                                                  (9)
1.      Union
2.      Bitwise operators
3.      Macro

Q-5      Answer any two:                                                                                                                                 (8)
a.       Write a recursive function to calculate x to the poser y, where x and y are two integer numbers.
b.      Explain the general format and use of fseek function.
c.       What do you understand by bit fields? Explain the advantages of using bit fields giving suitable example.

Q-6      Write menu driven program to create a linked list of a class of students (containing the name, age and
weight of each student) and perform the following operations:
i.                    write out contents of the list.
ii.                  Display the information of a specific student.
iii.                Count the number of students above a specific age and weight.

OR

Q-6      Write an interactive menu driven program that will access the data file containing list of students and

their corresponding telephone numbers, and do one of the following tasks:                                     (8)
i)                    Determine the telephone number of a specific student.
ii)                  Determine the student whose telephone number is specified.