Sunteți pe pagina 1din 8

SYSTEM SOFTWARE

CAP318
HOME WORK – III

Submitted to – Submitted by-


Lect. Mandeep Kaur Surendra
MCA 4th SEM
D3804A15
10806601

DECLARATION
It is declared by me that this assignment is purely my effort and I had done my
assignment of my own. I accept that I had taken the help of internet and
books of modern programming tools and technique but I had used my own
language while answering the questions of homework 1. I had tried my best
to make my assignment unique from other student.

DECLARED BY
Surendra
Part A

Q 1.With figure illustrate how loading and calling of a subroutine can be done
using dynamic linking.
Ans.
Dynamic linking involves loading the subroutines of a library into an
application program at runtime, rather than linking them in at compile time;
the subroutines remain as separate files on disk. Only a minimum amount of
work is done at compile time by the linker; it only records what library
routines the program needs and the index names or numbers of the routines
in the library.
The majority of the work of linking is done at the time the application is
loaded (lead-time) or during execution (runtime). The necessary linking
code, called a loader, is actually part of the underlying operating system. At
the appropriate time the loader finds the relevant libraries on disk and adds
the relevant data from the libraries to the process's memory space.

”loading
and calling of a subroutine using dynamic linking”

l
Load-and-call
“A subroutine is loaded and linked to the rest of the program when it is
first called usually called dynamic linking, dynamic loading or load on
call.”
Dynamically loaded must be called via an operating system service request.
Load-and-call service
1. OS examines its internal tables to determine whether or not the routine
is already loaded.
2. Routine is loaded from library
3. Control is passed from OS to the called subroutine
4. Subroutine is finished
5. Calling to a subroutine which is already in memory
6. Binding of the name to an actual address is delayed from load time until
execution time

Q2. Accessing a pointer is different from accessing a variable? Explain with


examples?
ANSWER: The pointer is store the address of other variable, and a variable is also
having address, so to access the variable the pointer concept is simple. First we
define the variable and assign the address of that variable to the pointer. The
concept of array is very much bound to the one of pointer. In fact, the identifier of
an array is equivalent to the address of its first element, as a pointer is equivalent
to the address of the first element that it points to, so in fact they are the same
concept. There are some valid and invalid declarations are given below:

1. Int array [25];

2. Int * p;

p = array;

After that, p and array would be equivalent and would have the same properties. The
only difference is that we could change the value of pointer p by another one,
whereas array will always point to the first of the 25 elements of type int with
which it was defined. Therefore, unlike p, which is an ordinary pointer, array is an
array, and an array can be considered a constant pointer. Therefore, the following
allocation would not be valid:
array = p;
Because array is an array, so it operates as a constant pointer, and we cannot
assign values to constants.
Due to the characteristics of variables, all expressions that include pointers in the
following example are perfectly valid:

There is an example to access the element of an array.


#include <iostream.h>
Using namespace std;

int main ()
{
int array[6];
int * p;
p = array; *p = 20;
p++; *p = 21;
p = &array [2]; *p = 22;
p = &array +[3]; *p =23;
p = array; *(p+4) = 24;
p=&array[5];*p=25;
For (int k=0; k<6; k++)
Cout<<”the array elements are : ”;
Cout << array[k] << ", ";
Return 0;
}

Output of the program is : -


The array elements are :
20,21,22,23,24,25
Q3. Discuss various data types and data structures used in a programming
language.
Ans. A data type in programming languages is a set of values and the operations on
those values. There are some common data types.
1. Integers: it includes the integer type data, i.e. int a=10;
2. Floating-point numbers (decimals): it includes the floating or decimal
numbers, i.e. float a=22.5
3. Alphanumeric strings: it includes the alphanumeric data, i.e. rm20
4. Character strings: This is used in the three way:
o As length operator
o Concatenation operator
o Substring operator

5. Bit string –boolean: this is used for three following operation:


• Logical AND
• Logical OR
• Logical NOT

Data structures are used in almost every program or software system. Specific
data structures are essential ingredients of many efficient algorithms, and make
possible the management of huge amounts of data.
Types of Data Structure:
• Linear/Branching — There is only one direction to go, yet different paths can
be taken. This structural form is hierarchical and organized.
Examples are Arrays, Linked list, Stack, Queue.
• Nonlinear/Matrix — There are many directions to go. One can enter at any
point and move to any other point at any time. All directions and points can be
equally reached.
Examples are Trees, B-Trees, and Graph.
• Random/Schizo — all directions are equal and unequal at the same time. This
structure is more theoretical, and represents neurological and psychological
depths. A computer or algorithms can never truly repr.
• Abstract data type- A data structure that is defined indirectly by the
operations that may be performed on it, and the mathematical properties of
those operations

Part B
Q1. Why macro is said to be recursive?
ANS.
MAINED allows a macro to invoke itself. Macros that invoke themselves are called
recursive macros. A recursive macro executes until some command in its definition
command sequence fails. For example, the search and skip commands fail when they
cannot find their targets. On some operating systems, it is also possible to terminate
recursive macro execution with the <abort> key.
It is the "internal" version of the macro transition that is called recursively. There is no
respawning included in the definition of this "internal" version other than that caused
by recursive calls.
If a macro does call itself that call must be within a conditional block that eventually is
skipped over. Macros of this sort are called recursive macros,
The macro declaration is
Macro macro_name //macro declaration
Statements
-------------------
Mend //end of macro

Q2. How a program differs from a macro?

ANS.

MACRO

Macro programs are also referred to as macro recorder, macro software, macro automation
program, keyboard macro, etc.

Macro programs are a great productivity tool. They allow you to perform an otherwise long,
boring or complex task just by a single click.
I classify macros programs into 2 types.

1. Macro recorder: These provide record macro and re-play macro capabilities. You do not
need to know programming.
2. Macro Automation software: These offer a small macro language of its own in addition
to providing macro recording and re-play capabilities. Using macro automation software
you can record a macro or automation script and then use an editor to edit the script, add
new actions to a macro script or even write a macro from scratch using simple macro
language.

Program:

An organized list of instructions that, when executed, causes the computer to behave
in a predetermined manner. Without programs, computers are useless.

A program is like a recipe. It contains a list of ingredients (called variables) and a list
of directions (called statements) that tell the computer what to do with the variables.
The variables can represent numeric data, text, or graphical images.

There are many programming languages -- C, C+


+, Pascal, BASIC, FORTRAN, COBOL, and LISP are just a few. These are all high-
level languages. One can also write programs in low-level languages called assembly
languages, although this is more difficult. Low-level languages are closer to
the language used by a computer, while high-level languages are closer to human
languages.

Q3. Explain macro instructions with examples?


Ans.
A macro is the set of code of the programming language. We can say it is the part of a
computer program. In the macro instruction there is a prt of program available. Some
coding is available. It can be used by calling the macro. There are many programming
language such as FORTRAN AND COBOL. In other words the macro instruction is
effectively a middle step between assembly language programming and the high-level
programming languages

• Int max (int c, int a, int b) {vs. #define max(c, a, b) (c = ((a>b)? a: b))
c = (a>b)? Return a: return b;
}
• Int main () {
Int x=3, y=5, z=0;
Max (z, x++, y++);
Printf (“max of x=%d and y=%d is %d\n”, x, y, z);
}

S-ar putea să vă placă și