Tuesday, January 4, 2011

MCA FOP 2000


Gujarat University

MCA Semester I
FOP

Date: 11th January, 2000                   Marks:50

Section I


Q-1      What would following statement do?

            1. scanf (“%2d  %5d”, &num1, &num2)              [2]
                When the input is 3676727  25, what would be the values of num1 and num2?
            2. int a =20; int b=30; int c;
                c = a/b, now what ill be the value of c?           [1]
            3. int a =20; int b =5; int c;    
                How can one use bitwise operators to get c = a*b?     [3]
            4. int a=7;
                        printf (“%d  %d”, a--, a++);
                        What would be printed ? Explain.  1]
            5. Which of the following constants or variable are invalid? Explain.     [2]
1.      –1.79 e 4.2
2.      Column-Total
3.      3rd _raw
4.      ‘This is testing’

Q-2      Write programs for any two of the following:       [8]
a)      Read 100 integers from the keyboard one by one. Print the frequency of them in following manner.
1-20 < total no. of integers between 1 to 20 inclusive both>
21-40 <                                              21 to 40                      >
41-60 <                                              41 to 60                      >
61-80 <                                              61 to 80                      >
81-100 <                                            81 to 100                    >
100-     < Numbers greater than 100>
b)      Read an integer no from the keyboard and find out total no of zeroes from the entered no.
c)      Read a string from the terminal and fjind out if it is palindrome or not.
Ex. “madam” and “radar” are palindromes but “catch” is not.

Q-3      Write any four:                   [8]
1.      Explain the use of extern classifier with example.
2.      Explain recursion with example.
3.      What is the difference between break and continue? Explain with example.
4.      Explain the difference between for and while loop.
5.      Explain what is type casting with example.
6.      Y= 3x +5 if x >0
   = 2x – 0 if x<0
   = 0 if x =0
use ternary operator to represent above mentioned equation.

Section II


Q-4  a) Use a function with static variable to print each number of following series with successive calls.  [3]

            1, 3, 7, 13,……
        b) A C program contains the following statement     [4]
                        int i, j=25;
                        int *pi, *pj;
                        ……………..
                        &pj =j+ 5;
                        i = &pj + 5;
                        pi = pi*;
            Suppose each integer quantity occupies 2 bytes of memory. Value assigned at (Hexa decimal) address FAC and the value assigned to j begins at address FAE then
1.      What value is represented by &j?
2.      What value is assigned to pj?
3.      What value is represented by (*pi +2) and *(pi+2)?
c)      Write a macro WRITE which takes two arguments first being the variable to be printed and second being the type. Then an appropriate printf statement should replace it. Ex. WRITE (a,d) should be replaced by printf(“%d”, a);            [2]

Q-5      Write any two of the following:
1.      Write a program to read integers into a file. Then read the file into an array, sort the array and write the
data back to another file.
2.      Write a function to insert an element into a sorted linked list in an appropriate position. The function
should take the element and pointer to first element as an argument and return the pointer to first element back to main program. Main program is not required to be written.
3.      Write a program to take few integers from the command line and print the maximum of them.
Ex. Max    2          3          4          43        23        12 should display 43 as an answer.

Q-6      Define a structure for the following record for a player.    [8]
1.      team type (enumerated type only cricket or hockey can be valid values)
2.      player name (String 30 characters)
3.      country name (of five bits)                                                   
4.      category (of three bits)
for cricket players
5.      total_runs (of two bits)
6.      total-_wickets (of two bits)
7.      total_catches (of two bits)
for hockey players
            5.total_goals (of two bits)
            6. total_saves (of two bits)
            7. total_fouls (of two bits)
            field no. 5, 6 and 7 are to be unions. Now read information about 20 players with appropriate team type from the terminal (players can be either hockey players or cricket players but not both). Then read a team type from the terminal. Looking at the value of team type, display total number of players from the team and display their individual records.

OR

Q-6      Create a FIFO linked list and then store it into a file.