BPUT MCA 2007 - 2009 Solved Questions
BPUT MCA 2007 - 2009 Solved Questions
BPUT MCA 2007 - 2009 Solved Questions
Q1.
a. Compare the following and comment:
#include<stdio.h> and #include “stdio.h”.
Ans:
#include “stdio.h”: At this point, the pre-processor inserts the entire contents of stdio.h into
the source code of the program.
When the stdio.h is included within the double quotation marks, the search for the
file is made first in the current directory and then in the standard directories.
#include<stdio.h> : Here the compiler will search the file stdio.h only in the standard
directories.
b. Find the output of the following program segment:
int a = 5;
If (a = 7)
printf(“Equal%d”,a);
else
printf(“Not equal%d”,a);
Ans: Equal7, because the “test expression” of the if statement is a = 7, where the
assignment operator (=) is used. Which assign value 7 to the variable a and due to lake of the
relational operator the if condition is satisfied.
c. Find the output of the following program segments:
int I = 1;
printf(“%d”, i, ++i, i++);
Ans: 2, because the expression execute start from left to right inside the printf() function. So
the leftmost term i = 1, then ++i = 2 because it is prefix operator is used, then i++ can not
execute because of postfix operator. So the value of i = 2.
d. Find the output of the following program segments:
int i = 3, j;
j = i && 0 || i;
printf(“%d”, i);
Ans: 3, because the value of i is initialized to 3 at the declaration part, which is not changed
during next part of the program.
e. Write the conditions for which recursion can be used in place of looping.
Ans: 101, and the for-loop will executed 101 times, because i is initialized form 0 and the
condition is satisfied i.e. i <= 100.
h. Differentiate between a structure variable and a union variable.
Ans: Union:
Union allocates the memory equal to the maximum memory required by the
member of the union.
Here one block is used by all the member of the union.
Union is best in the environment where memory is less as it shares the memory
allocated.
Ans: It is a prarameter supplied to a program when the program is invoked. This parameter
may represent a filename the program should process.
e.g.: If we want to execute a program to copy the contents of a file named X_FILE to
another one named Y_FILE, then we may use a command line like
C> PROGRAM X_FILE Y_FILE
Where PROGRAM is the file name where the executable code of the program is stored. This
eliminates the need for the program to request the user to enter the filenames during
execution.
j. Differentiate between a macro and a function in C.
Ans: Macro:
Macro is preprocessed.
No type checking
Code length increases
Use of macro can lead to side effect
Speed of execution is Faster
Before Compilation macro name is replaced by macro value
Useful where small code appears many time
Generally Macros do not extend beyond one line
Macro does not Check Compile Errors
Function:
Function is compiled.
Type Checking is done.
Code Length remains same.
No side effect
Speed of Execution is slower
During function call, transfer of control takes place Useful where large code appear
many time.
Useful where large code appear many time
Function can be of any number of lines
Function checks Compile Error
Ans.:
* Control unit directing the processes of CPU, input units, output units, storage devices,
communication interface unit..
* The control unit in a CPU does the controlling.
1. a. A computer system has eight bit addressing. What is the range of addresses? What is
the total number of memory cells it can address?
Ans: Computer system having 8-bit addressing capacity can addresses form 0000 0000 –
1111 1111 range of address..
And
The total number of memory cell it can address is: 28 = 256 bytes.
b. What is flow chart? List out symbols used in writing flowchart.
Ans: Defn: Flowchart is a graphical representation of an algorithm.
All symbols are connected among themselves to indicate the flow of informationand
processes.
The following are the symbols used in flow chart:
1. Terminal
2. Flow Direction
3. Connector
4. Input-Output
5. Decision making
6. Annotation
7. Process
8. Looping Predefined Process
c. What is the difference between these two declarations?
struct x1 {….};
teypedef struct {…} x2;
Ans:
In the first case after the structure definition, whenever we have to declare a
structure variable we have to use struct x1 <variable name>. Here we have to use
the struct tag repeatedly.
But in the second case, the repeatedly writing of struct tag is eliminated by using the
typedef keyword by x2 user-defineed structure type.
Here we can declare a structure variable in following manner:
x2 <variable name>;
d. What is meant by the equivalence of pointers and array in C?
Ans:
Equivalence of using pointer:
Pointer are more efficient in handling arrays and data tables.
Pointer can be used to return multiple values from a function via function
arguments.
Pointer permit references to function and thereby facilitating passing of functionsas
arguments to other functions.