answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What is stack segment?

I will start with a small explanation. An object code genearated by a compiler or assembler by processing a source code file, is structured as blocks of data called segments, each contain a certain type of data. The types supported are the following. BSS or Block started by symbol, Text/code , data, heap and stack.

Data Segment - global and static data which are initialized to non-zero

BSS - global and static data which are initialized to zero

Heap - dynamically allocated variables

The above three are often referred together as data-segment

Text/Code - contains machine instructions / executable computer instructions

Stack - contains local/auto variables,which will be pushed in and popped out during the call to the function.

ang tinda ni cha bating na okuy ay masiramon..bakal na kamo!! tapos si chu ruben ay pasmado na kakakayo...nag niriwang na! tenk you..eyo man lang tabi.

Example of sort program in easytrieve?

You can sort the output using the keyword 'SEQUENCE'.

PRINT PAY-RPT

REPORT PAY-RPT LINESIZE 80

SEQUENCE DEPT

CONTROL DEPT

SUM GROSS

TITLE 01 'PERSONNEL REPORT EXAMPLE-1'

HEADING NAME ('EMPLOYEE' 'NAME')

LINE DEPT NAME EMP# GROSS NET-PAY DEDUCTIONS

Is it true that the only way to transfer control from one place in the program to another in OOP is by using goto statement?

No. That is only true in procedural languages. Although it is permitted to use goto statements in structured and object oriented languages, its usage is limited to local scope only, which reduces the "spaghetti code" that was prevalent in all procedural languages, and still is in low-level assembler and machine code.

What facility static gives in class?

Static variables or function provides global view to the application that is u can access a static variable with one or more than one objects of a single class without loosing i.e. reinitializing its value.

Write a routine to implement the t e x t function?

There are many ways you could write a routine to implement text functions. You could, for example, come up with codes.

How do you think that hackers may be able to blackmail companies?

well maybe by hacking into their entire database, splicing encrypted files, finding bad information the company has payed millions to keep hidden. then, the hacker uses the information and says 'pay me a million or else

What is the decimal equivalent of 1111 in binary?

1111 converted from binary (base 2) to decimal (base 10) is 15

When you expand the steps...

1111 binary

= (1 X 2^3) + (1 X 2^2) + (1 X 2^1) + (1 X 2^0)

= 8 + 4 + 2 + 1

= 15

When a object is passed to a function as argument why it is not generating an error if the parameterized constructor is defined and not the default constructor?

default constructor is used only when the programmer does not use a constructor to initialize objects. Once the programmer defines a constructor then the default constructor is no longer used

How do you attach parity bit in c language?

for example:

unsigned char attach (unsigned char byte, unsigned char bit)

{

unsigned char mybyte;

mybyte = byte&0x7f;

if (bit) mybyte |= 0x80;

return mybyte;

}

Write a shell program to find given no is even or odd?

The pseudo code would be as follows (you figure out the syntax)

1) Prompt the user to enter a number

2) If entered number is alpha, quit program after displaying message that the user ended the program.

3) Otherwise, find Modulo 2 of the entered number. This is a fancy way of saying "find the remainder when the number is divided by 2)

4) If Modulo 2 is zero, the number is even, otherwise odd

5) Display message showing if the entered number was Even or Odd

6) Branch back to step 1

What is a program that produces an onscreen or printed document from all or part of a datbase?

report generator

************************************

A database on a spreadsheet that could be used in a mail merge to produce a document. There are other database programs that would save, sort, and produce a document - LibreOffice Base is one I often use (but then, I use Ubuntu, and don't use MS Windows!).

What is the difference between a string and an array?

Nothing whatsoever. A string is simply an array of type char.

In some programming languages, such as C, a string is an array of char (or short), terminated with a null \0.

An array is just a fixed size of collection, a container to hold things/objects. If all the elements in the container are characters (of char), then we may call it a string, sometimes a byte array (because each character can be represented as a byte).

An array of 7 different days, it maybe a WEEK, or just the birthdays of 7 dwarfs. Then they are nothing to do with strings.

A data item (or variable) is described as a "string" type when it contains some number of characters. Those characters can usually be anything in the system's accepted list of codes. Most systems use ASCII, so a string can include the letters a-z, A-Z, numbers 0-9, and special characters like ~!@#$%^&*()_+-=[]\{}|:";'<>?,/. A string is treated as a single object, although most programming languages have methods to break strings apart (called sub-stringing). In the Perl language, strings are named $something.

An array is a collection of individual data items, sort of like a list. Each element in an array can be referred to in a program by its position in the list. In the Perl language, an array would be named @SOMETHING. The first element in the array would be named $SOMETHING[0], the second $SOMETHING[1], and so on. Each element can be a string, or some other data type.

Other data types would be integers (positive or negative whole numbers), floating point (decimal numbers like 3.14159 or 2398.41; it can be more complicated than this, but that's another story), and a few more exotic types.

In the C programming language a string is actually the same as an array of characters. The last character in a C string is a zero byte which indicates the end of the string.

Write a programme in 8086 assembly language that accepts two input digits and creates a packed BCD number in AL register?

There should be a jump over the variables/array declaration:

org 100h

jmp code

myArray dw 2, 12, 8, 52, 108

code: mov si, 0

mov ax, myArray[si]

ret

For the computer all bytes look the same, it cannot determine if it's an instruction or a variable. Here is an example of MOV AL, 5 instruction that can be coded with simple variable declarations:

org 100h

byte1 db 176

byte2 db 5

ret

When you run this program in emulator you can see that bytes 176 and 5 are actually assembled into:

MOV AL, 5

This is very typical for Von Neumann Architecture to keep data and instructions in the same memory, It's even possible to write complete program by using only DB (define byte) directive.

org 100h

db 235 ; jump...

db 6 ; 6 - six bytes forward (need to skip characters)

db 72 ; ascii code of 'H'

db 101 ; ascii code of 'e'

db 108 ; ascii code of 'l'

db 108 ; ascii code of 'l'

db 111 ; ascii code of 'o'

db 36 ; ascii code of '$' - DOS function prints until dollar.

db 186 ; mov DX, .... - DX is word = two bytes

db 2 ; 02 - little end

db 1 ; 01 - big end

db 180 ; mov AH, ....

db 9 ; 09

db 205 ; int ...

db 33 ; 21h - 33 is 21h (hexadecimal)

db 195 ; ret - stop the program.

8086 and all other Intel's microprocessors store the least significant byte at a lower address. 102h is the address of 'H' character = org 100h + 2 bytes (jmp instruction). The above assembly code produces identical machine code to this little program:

org 100h

jmp code

msg db 'Hello$'

code: mov DX, offset msg

mov AH, 9

int 21h

ret

If you open the produced ".com" file in any hex editor you can see hexadecimal values, every byte takes two hexadecimal digits, for example 235 = EB, etc... memory window of the emulator shows both hexadecimal and decimal values.

What is sparce array?

sparse array is one which has contents lower than its maximum size, that is the array has free or empty locations....