answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What is a project data book?

A project data book is your most treasured piece of work. accurate and detailed notes make a logical and winning project. good notes show consistency and thoroughness to the judges and will help you when writing your research paper. Data tables ate also helpful. they may be a little 'messy' but be sure the quantitative data recorded is accurate and that units are included in the data tables. make sure you data each entry.

Advantages of dynamic binding?

There is Static binding and also Dynamic binding. The compiler has to choose from one or the other. Stactic binding defines the properties of the variables at compile time. Therefore, they can't be changed. In dynamic binding the properties of the variables are determined at runtime. Since the variables can change in form, dynamic binding is more flexible but slower. A great example is given in wikipedia it states: Suppose all life-forms are mortal. In object oriented programming, we can say that the Person and Plant classes must implement the Mortal interface, which contains the method die(). Persons and Plants die in different ways; for example, Plants do not have hearts that stop. Dynamic binding is the practice of figuring out which method to invoke at runtime. For example, if we write void kill(Mortal m) { m.die(); } it's not clear whether m is a Person or a Plant, and thus whether Plant.die() or Person.die() should be invoked on the object. With dynamic binding, the m object is examined at runtime, and the method corresponding to its actual class is invoked.

How many times will a digital clock display 3 or more of the same number in a row over the course of 1 day?

34 times...I think.

12:22am

1:11am

2:22am

3:33am

4:44am

5:55am

10:00am

11:10am

11:11am

11:12am

11:13am

11:14am

11:15am

11:16am

11:17am

11:18am

11:19am 12:22pm

1:11pm

2:22pm

3:33pm

4:44pm

5:55pm

10:00pm

11:10pm

11:11pm

11:12pm

11:13pm

11:14pm

11:15pm

11:16pm

11:17pm

11:18pm

11:19pm Don't say I think, By Brooke You have got it!!! 11:01 is not 3 in a row.

What is Code segment in C program?

A code segment, also known as the text segment holds all the executable instructions of the process. The text segment usually starts from the lowest address space of the process memory (leaving behind a small unmapped memory ..not mapped to a physical memory)

--Vivek Purushotham

(vivek.purushotham@gmail.com)

What are the advantages disadvantages of testing APIs i.e application programming interface in cplusplus?

Advantages: * Absolute minimum barrier to use - By not using encryption or special authentication methods, anyone with access to the Internet should be able to begin working with your API quickly. * Easily distributed code - Login accounts or developer key programs that make use of your API can be widely distributed and used right out of the box. * Less to worry about - If you aren't managing user accounts or development keys, it's one less thing to keep track of, and your code efforts can concentrate solely on developing the API itself. Disadvantages: * No control - Anyone, anywhere, can use the API, and while this may sound like the goal of web services, it drastically limits your response if abuse requests begin pouring in. If those requests are coming from an application on a single machine, it is easy enough to recognize the requests and block them at the firewall. But should an application that behaves poorly reach wide distribution, you will have a very difficult time dealing with the requests. * No encryption - All requests and responses are visible to anyone between the requesting server and the API server. * Can't contact developers - Because anyone anywhere can access the API without any prior registration, you are left without any method of directly engaging developers using the API. You may want to contact developers in situations where their application is being abusive, when changes are being made to the API that will affect their application, or to seek suggestions on how to improve the API itself. * Abuse - Unfortunately today, systems with little or no security or authentication make prime targets for abuse by some less ethical elements out there.

Examples of non-numerical data?

We'd need more of a context. In life, my name, hair color, weight, hometown, favorite band, food I ate, friends, etc., are all data, and probably don't contain too many numbers.

In computers everything is stored as a binary number. So, non-negative integers are pretty easy to store. Negative integers take just a little bit more thinking (read up on 2's complement).

Float-type numbers have 2 parts, the exponent and the mantissa, where each part has a sign bit.

Strings are sequences of characters. A character is stored as an integer, and looked up in a table, when it actually needs to be displayed. E.g., 'A' is 6510 in the ASCII table.

Other, more complex data, is made up of collections of numbers and strings. Homogeneous collections are lists or vectors of, for example, integers, or strings, or other lists. Heterogeneous data is a collection of different types. E.g.:

A person might have these attributes, on a driver's license:

name

address

age

hair color

weight

license #

Name and address would be strings. A simple age would be an integer. A birthday is a little more complex, but can be represented using an integer, or maybe a couple integers.

Weight is an integer, or possibly a float type.

Since there are usually only a few pre-defined choices for hair and eye color, we might enumerate (assign integers to) them, to save storage space.

ID "numbers", zip codes, phone numbers should be stored as strings. We might call them numbers, but, it doesn't make sense to do arithmetic on these things, so...

Difference between human readable and machine readable?

Human readable can only be understood by human beings where as Machine readable is in Binary format and could only be understoood by machines. (eg. computers) The only way to understand machine readable is if the data is processed and output into human readable form by means of an output device :)

What are the most common syntax errors in LISP programs?

Incorrect placement or number of parentheses will probably make the most common syntax error in LISP programs.

What is difference between markov process and semi-markov process?

A continuous-time stochastic process is called a semi-Markov process or 'Markov renewal process' if the embedded jump chain (the discrete process registering what values the process takes) is a Markov chain, and where the holding times (time between jumps) are random variables with any distribution, whose distribution function may depend on the two states between which the move is made. A semi-Markov process where all the holding times are exponentially distributed is called a continuous time Markov chain/process

Difference between pointer to constant and constant pointer?

1. pointer to a constant means you can not change what the pointer points to

2. constant pointer means you can not change the pointer.

What is scatter gather algorithm?

It is a class of algorithms that are fine-tuned towards making the best out of a distributed computing ( similar to cloud computing ) environment. A very good example of such an algorithm is MapReduce (see wikipedia).

2 types of identifiers in C programming language?

1. identifiers beginning with a letter

2. identifiers beginning with an underscore

What Windows 2000 and XP tool can you use to view the number of partition used by the harddrive?

Control Panel > Administrative Tools > Computer Management > Storage > Disk Management.

Assembly language for sudoku puzzle?

TITLE sudoku

; Program Description:

; This program is a sudoku game generator and sudoku puzzle solver.

; According to the choices on the program you will chose if you want to produce a new puzzle, or to make the computer solve a puzzle given by you.

; When you chose to make the computer solve the puzzle for you, you will have to enter the number of values that the puzzle contains, and then, you will enter the non-zero

; values by firsly entering their coordinates (i and j). Attention! Enter the coordinate considering the puzzle a 2-dimensional array, which starts from index 0.

; so give the i and j values inside the range : [0, 8]

.386

.model flat

; there are the prototypes of the procedures used in this program. They will be explained by adding comments in the beggining of each procedure inside dhe program code. Also there will be comments inside the procedures.

public _solver

public _generate

public _hideCells

public check_initial_puzzle

public solve

public check

public checkColumn

public checkColumn

public getValue

public checkGroup

public check_coordinate

public backtracking

public inc_current_value

public make0_current_value

grid EQU [ebp+8]

used_i EQU [ebp+12]

used_j EQU [ebp+16]

n EQU [ebp + 20]

seed EQU [ebp + 24]

.data

value DWORD ?

counter DWORD 0

; group_i and group_j are the initial coordinates for a group. There are totally 9 groups. for example the first group's coordinate is 0, 0. The group found right to this has the coordinate 0, 3. and so on.

group_i DWORD ?

group_j DWORD ?

; current_i and current_j are very used in this program code, because almost all procedures need these two variables which are global.

; they express the current i and current j coordinates being currently used. So for example, when e procedure modifies them , there may be another procedure which takes the data stored in these 2 variables and manipulates it.

current_i DWORD 0

current_j DWORD 0

; this is a boolean which is 1 in case that the cell can be filled

;and it is 0 when the cell cannot be filled because it is the constant value comming in the sudoku puzzle.

not_constant DWORD ?

; index is used to move inside an array

index DWORD 0

; this is a string containin the 1-9 values which will be put randomly on an empty grid, after that the solve procedure is called in order to solve this grid

; and as a result a new solved random puzzle will be generated

one_to_nine DWORD 1,2,3,4,5,6,7,8,9

; the seed is taken from the main.cpp and it is stored in seed_value. after that the program changes it addind values of the adresses of the esi where currently

; the esi points. It is done in order to generate random values and in each program start these random values will be different, because seed takes the value from the function GetTickCount()

seed_value DWORD 0

no_solution DWORD 0

.code

; The solve procedure is the place where other procedures are called in order to make this program work correctly. The algorithm to solve the sudoku puzzle consists on

; the bactracking rules. So it is something like brute-force but it has a better efficciency because when trying the new value it firstly checks the column, row and group.

; All the entered value's coordinates are stored in the used_i and used_j, which using the same index respectively, they express a value found in the grid (which is our puzzle)

; For example, let's assume that the value X has the coordinate i=4, j=6 and using the same index the coordinates are stored in used_i and used_j. for example used_i[index] and used_j[index]

solve PROC NEAR

mov esi, grid ;esi points to the start of the grid adress

mov current_i, 0

mov current_j, 0

loop_i:

loop_j:

cmp current_i, 8

jg out_i

cmp current_j, 8

jg out_j

call check_coordinate

cmp not_constant, 0

je next_cell

next_value:

cmp no_solution, 1

je there_is_no_solution

call inc_current_value

call getValue

cmp value, 9

jg backtrack

call check

cmp eax, 0

jne next_value

jmp next_cell

;call inc_current_value

backtrack:

call make0_current_value

call backtracking

jmp next_value

next_cell:

inc current_j

jmp loop_j

out_j:

inc current_i

mov current_j, 0

jmp loop_i

there_is_no_solution:

mov eax, 0

jmp end_solving

out_i:

mov eax, 1

end_solving:

ret

solve ENDP

_solver PROC NEAR

push ebp

mov ebp, esp

push esi

call check_initial_puzzle

cmp no_solution, 1

je wrong_puzzle

call solve

jmp ok

wrong_puzzle:

mov eax, 0

ok:

pop esi

pop ebp

ret

_solver ENDP

; here is the procedure which will generate current_i and current_j randomly. In the same time, the string one_to_nine is read, and its elements are taken one by one and put in the grid.

_generate PROC NEAR

push ebp

mov ebp, esp

push esi

mov esi, used_i

mov ecx, 9

mov eax, seed

mov seed_value, eax

randomizing_i:

add seed_value, esi

;multiplying the seed_value with itself will make a new one, so the there will be a more random number to be generated

mov eax, seed_value

mov ebx, seed_value

mul ebx

add seed_value, eax

mov eax, seed_value

mov edx, 0

mov ebx, 9

div ebx

mov DWORD PTR [esi], edx

add esi, 4

loop randomizing_i

mov esi, used_j

mov ecx, 9

randomizing_j:

add seed_value, esi

mov eax, seed_value

mov edx, 0

mov ebx, 9

div ebx

mov DWORD PTR [esi], edx

add esi, 4

loop randomizing_j

mov esi, used_i

mov edi, used_j

mov index, 0

mov ecx, 9

put_on_grid:

mov eax, DWORD PTR [esi]

mov current_i, eax

mov eax, DWORD PTR [edi]

mov current_j, eax

push esi

mov esi, grid

mov eax, current_i

mov ebx, 9

mul ebx

add eax, current_j

mov ebx, 4 ;because each record contains 4 bits (DWORD)

mul ebx ;now in eax is stored the index of the value to check

add esi, eax

mov eax, index

mov eax, one_to_nine[eax]

mov DWORD PTR [esi], eax

pop esi

add esi, 4

add edi, 4

add index, 4

loop put_on_grid

call solve

pop esi

pop ebp

ret

_generate ENDP

; after generating the new sudoku puzzle, the user may want to hide some cells in order to make this a real puzzle which can be solved.

_hideCells PROC NEAR

push ebp

mov ebp, esp

push esi

mov esi, grid

mov eax, seed

mov seed_value, eax

;70 means the number of loops to be made, so it means the number of new random coordinates. Many times, it may be possible that the same coordinate is generated. So it will put zero in the same coordinate. So, normally there are never 70 zeros in the puzzle.

mov ecx, 70

hiding:

mov eax, seed_value

mov edx, 0

mov ebx, 81

div ebx

mov seed_value, eax

mov eax, edx

mov ebx, 4

mul ebx

push esi

add esi, eax

;multiplying the seed_value with itself will make a new one, so the there will be a more random number to be generated

mov eax, seed_value

mov ebx, seed_value

mul ebx

add seed_value, eax

mov DWORD PTR [esi], 0

pop esi

loop hiding

pop esi

pop ebp

ret

_hideCells ENDP

; check groups the 3 other procedures to check the row, column and group

; if all of them result ok, also check procedure results ok.

check PROC

push esi

call checkGroup

cmp eax, 1

je wrong

call checkRow

cmp eax, 1

je wrong

call checkColumn

cmp eax, 1

je wrong

jmp true

wrong:

mov eax, 1

jmp end_of_check

true:

mov eax, 0

end_of_check:

pop esi

ret

check ENDP

checkRow PROC

mov esi, grid ;esi points to the start of the grid adress

call getValue

mov ecx, 9

mov esi, grid

mov eax, current_i

mov ebx, 9

mul ebx

mov ebx, 4

mul ebx

add esi, eax

mov counter, 0

check_row:

mov eax, DWORD PTR [esi] ; one value of the current row

cmp eax, 0

je inRow_not_equal ; if it is 0, it means that there is an empty place which should not be considered temporarily

cmp value, eax

je inRow_is_equal

jmp inRow_not_equal

inRow_is_equal:

add counter, 1

inRow_not_equal:

add esi, 4

loop check_row

cmp counter, 1

jg inRow_not_correct

mov eax, 0 ; 0 means that the value can be put on that row

jmp inRow_ending

inRow_not_correct:

mov eax, 1 ; 1 means that the value can't be put on that row

inRow_ending:

ret

checkRow ENDP

checkColumn PROC

mov esi, grid ;esi points to the start of the grid adress

call getValue

mov ecx, 9

mov esi, grid

mov eax, current_j

mov ebx, 4

mul ebx

add esi, eax ;now, esi is the index of the head of the column

mov counter, 0

check_column:

mov eax, DWORD PTR [esi] ; one value of the current row

cmp eax, 0

je inCol_not_equal ; if it is 0, it means that there is an empty place which should not be considered temporarily

cmp value, eax

je inCol_is_equal

jmp inCol_not_equal

inCol_is_equal:

add counter, 1

inCol_not_equal:

add esi, 36 ; add 9*4 in order to pass in the next row, but remain still in the same column

loop check_column

cmp counter, 1

jg inCol_not_correct

mov eax, 0 ; 0 means that the value can be put on that row

jmp inCol_ending

inCol_not_correct:

mov eax, 1 ; 1 means that the value can't be put on that row

inCol_ending:

ret

checkColumn ENDP

getValue PROC

mov eax, current_i

mov ebx, 9

mul ebx

add eax, current_j

mov ebx, 4 ;because each record contains 4 bits (DWORD)

mul ebx ;now in eax is stored the index of the value to check

mov eax, DWORD PTR [esi + eax]

mov value, eax

ret

getValue ENDP

checkGroup PROC

mov esi, grid ;esi points to the start of the grid adress

call getValue

mov eax, current_i

cmp eax, 3

jb i_smaller_than3

cmp eax, 5

jg i_greater_than5

mov group_i, 3

jmp i_found

i_smaller_than3:

mov group_i, 0

jmp i_found

i_greater_than5:

mov group_i, 6

i_found:

mov eax, current_j

cmp eax, 3

jb j_smaller_than3

cmp eax, 5

jg j_greater_than5

mov group_j, 3

jmp j_found

j_smaller_than3:

mov group_j, 0

jmp j_found

j_greater_than5:

mov group_j, 6

j_found:

;now, we have the initial coordinates of the group : group_i and group_j.

mov eax, group_i

mov ebx, 9

mul ebx

add eax, group_j

mov ebx, 4 ;because each record contains 4 bits (DWORD)

mul ebx ;now in eax is stored the index of the value to check

add esi, eax ;esi has the adress of the initiation of the group index

mov ecx, 3

mov counter, 0

check_group:

push ecx

mov ecx, 3

checkRowInGroup:

mov eax, DWORD PTR [esi]

cmp eax, 0

je inGroup_not_equal ; if it is 0, it means that there is an empty place which should not be considered temporarily

cmp value, eax

je inGroup_is_equal

jmp inGroup_not_equal

inGroup_is_equal:

add counter, 1

inGroup_not_equal:

add esi, 4

loop checkRowInGroup

pop ecx

add esi, 24 ; 6*4 = 24 This means that 6 cells will be passed in order to go to the next row of the same group

loop check_group

cmp counter, 1

jg inGroup_not_correct

mov eax, 0 ; 0 means that the value can be put on that row

jmp inGroup_ending

inGroup_not_correct:

mov eax, 1 ; 1 means that the value can't be put on that row

inGroup_ending:

ret

checkGroup ENDP

; when giving the initial puzzle there are some cells which cannot be modified because they are given as a default. These coordinates expressing these cells are stored in the used_i and used_j arrays.

; this procedure checks the current_i and current_j if they are showing a cell which cannot be modified by the program.

check_coordinate PROC

push esi

push edi

mov not_constant, 0 ;initalize not_constant as false

mov esi, used_i

mov edi, used_j

mov ecx, n ; or used_i. this is the loop to check if that coordinate already exists in the board like a default puzzle value.

check_coord:

mov eax, DWORD PTR [esi]

cmp eax, current_i

jne value_no_exist

mov eax, DWORD PTR [edi]

cmp eax, current_j

je end_check ; the coordinate can't be changed. because there is a puzzle value in here, which is given in the initial unsolved puzzle.

value_no_exist:

add esi, 4

add edi, 4

loop check_coord

mov not_constant, 1 ; the required coordinate can be used because it is free.

end_check:

pop edi

pop esi

ret

check_coordinate ENDP

; this procedure goes back in the grid, but is uses the current_i and current_j values. If in a cell all the values from 1-9 are tried but none of them is possible to be put,

; then the backtracking procedure will decrease the current position and will go to a modifiable cell. And the job of backtracking finishes here.

backtracking PROC

backtrack_i:

cmp current_i, 0FFFFFFFFh

je wrong

backtrack_j:

dec current_j

cmp current_j, 0FFFFFFFFh

je out_backtrack_j

call check_coordinate

cmp not_constant, 0

je backtrack_j

jmp out_backtracking

jmp backtrack_j

out_backtrack_j:

mov current_j, 8

dec current_i

call check_coordinate

cmp not_constant, 0

jne out_backtracking

jmp backtrack_i

wrong:

mov no_solution, 1

out_backtracking:

ret

backtracking ENDP

; this procedure takes the grid adress (which is stored in esi), current_i and current_j. After thinking this as a 2-dimensional table, it calculates the value and uses it in the 1-dimensional grid.

; As it is seen below, it is multiplied by 4 because it uses DWORD and it is composed of 4 bits.

inc_current_value PROC

mov esi, grid

mov eax, current_i

mov ebx, 9

mul ebx

add eax, current_j

mov ebx, 4 ;because each record contains 4 bits (DWORD)

mul ebx ;now in eax is stored the index of the value to check

inc DWORD PTR [esi + eax]

ret

inc_current_value ENDP

; this is like the inc_current_value but instead of increasing the value it makes it 0.

make0_current_value PROC

mov esi, grid

mov eax, current_i

mov ebx, 9

mul ebx

add eax, current_j

mov ebx, 4 ;because each record contains 4 bits (DWORD)

mul ebx ;now in eax is stored the index of the value to check

mov DWORD PTR [esi + eax], 0

ret

make0_current_value ENDP

check_initial_puzzle PROC

mov esi, used_i

mov edi, used_j

mov ecx, n

checking_puzzle:

mov eax, DWORD PTR [esi]

mov current_i, eax

mov eax, DWORD PTR [edi]

mov current_j, eax

push ecx

call check

pop ecx

cmp eax, 0

jne wrong_puzzle

add esi, 4

add edi, 4

loop checking_puzzle

jmp end_checking

wrong_puzzle:

mov no_solution, 1

end_checking:

ret

check_initial_puzzle ENDP

end

What is difference between single double and circular buffer?

single buffer : you read and write on the same buffer, can be messy if both reading and writing take place at the same time.

double buffer : you read one buffer and you write the other one. When both reading and writing are complete, the buffers are swapped. It solves the problem of simultaneous reading and writing but requires synchronization.

circular buffer : this a buffer with two pointer : read and write. If both pointers are equal, the buffer is empty.
For each write operation, the write pointer advances and each time data is read back, the read pointer advances. It is circular because when a pointer reaches the end, it wraps back to the beginning.
It may be used to implement a queue which allows simultaneous reading and writing without synchronization as long as the buffer is not full.

A double buffer is basically a circular buffer of size 2 and a single buffer is basically a circular buffer of size 1.

What is Instance Recovery?

Brand computers usually has a concealed sector where installed the original operation system. Your so-called Instant Recovery is to pretty much erase everything you have in your computer(virus included) and it loads with the the operation system just like when you first bought it.

What does hook mean in programming language?

A hook is a method of interposing a piece of code in front of another piece of code, so that the first piece of code executes before the second piece of code, giving the first piece of code an opportunity to monitor and/or filter the behavior of the second piece of code. An example might be a mouse hook, allowing the hook code to monitor the mouse while at the same time preserving the functionality of the original mouse event processing routine.

What are special purpose language tools?

They are also called domain language. They are language whose sole creation is to handle problems in a paticular domain. Examples:

Html for web pages

Actionscript for animation

Mathematica for science

How do you convert pmd file to pdf file?

This is is a simple by iPubsoft PDF Creator, lightweight, drag-and-drop application that will allow you to make a PDF document from image, text and Word .docx files. The most attractive point is its facilitating batch mode processing, which can save you much time if you have a number of files to be dealt with. Following are simple steps to tell you how to make PDF files on Mac OS X with this powerful program.

1.Import Image or Text File(s)

After launching the program, the first thing is to choose conversion type: Image to PDF, Text to PDF or Word to PDF. In Image to PDF mode, you can convert JPG, PNG, BMP, GIF, TIFF as well as other image types to PDF format. In Text to PDF, you can get a created PDF from plain TXT files. And in Word to PDF, you can create PDF from DOCX files.

Click Add File to import your desired pictures or text files. If you have a whole folder for conversion, hit the Add Folder button to load what you want. If the files are successfully imported, you can see the file information listed in the file list like the file name, size, etc.

2.Customize Output Folder

Select an output directory for saving your created PDF by hitting the small ellipse button - Browse.

3.Start PDF Creation

Once all necessary settings done, you can click the bottom right button Start to begin creating PDF files on Mac. A few seconds later, the process can be finished. Now you can hit the Open button to view the result.

4.Optional settings

Merge function:

Sometimes, you may need to merge multiple image files or text files into one single PDF document. The merge function of iPubsoft will be helpful.