answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What is GW-BASIC?

Several theories are in circulation regarding the full form of GWBASIC. According to Greg Whitten (an early Microsoft employee who developed the standards in the company's BASIC compiler line) GWBASIC stands for "Gee-Whiz Beginner's All-purpose Symbolic Instruction Code". One more full form is in circulation and is "Gates-Whitten Beginners All Purpose Symbolic Instruction Code" (because Bill Gates and Greg Whitten were the primary developers of the language). according to other sources,GWBASIC stands for.... ''Graphics Workstation Beginers All popose Symbolic Instruction Code"

How xml works in simple language?

XML is abbreviated for Extensible Markup Language and is used to define data which can be readble by machine and human both. It is a software and hardware independent tool.

What is an analog signal and a digital signal?

An analog signal is one which is continuous in time as well as continuous in amplitude . Example : sine wave, cosine wave. An Digital signal is one which is continuous in discrete in time. Example : square waves.

How did the microprocessor change computers?

The micro processor made today's computer possible.

Pre-microprocessor computers, while being ingenious engineering accomplishments, are outperformed by microprocessor based systems by an order of magnitudes. Even microprocessor based systems from over a decade ago, in terms of speed and complexity of calculations, general purpose use, power consumption, physical size, reliability and cost.

Is encapsulation a characteristic of procedural or object oriented programming?

Encapsulation is one of the four pillars of object-oriented programming. The other three are inheritance, polymorphism and abstraction.

Explain the linked list and multi linked list structures?

I tried my best to explain all Linked List.

For Single Linked List http://www.fansonnote.com/2012/02/single-linked-list/

For Double Linked List http://www.fansonnote.com/2012/02/double-linked-list/

For Multi Linked List http://www.fansonnote.com/2012/02/multi-linked-list/

Hope it will help.

Thanks.

What does a math diagram look like?

the bohr diagram is a series of circles with the element in the middle

Is the cost of creating a process or a thread higher?

Raj, Processes are ALWAYS more expensive than threads. Threads are considered a component of a process. That is...a process can consist of several threads of execution. The exact "cost" in memory, or allocation of time depends on the operating system, but a thread is frequently 10% or less than the "cost" of a process.

AnswerWell this answer seems to be like what do you think of whether putting a new task force to do same task is Costly or using the same task force to do it for yourself when having one factory for processing in a pretty cooperative way, the answer is as usual putting same task force and that is why processes are heavy and threads are light. Because each time allocatin a new process means to launch a new set of each resources needed for its execution while Thread share some props in common that doesn't need to be reallocated and those behave like shared buffers or resources. For more refer to any O/S book.

What is the difference between macro and inline function in c plus plus?

Macros are not actually part of the C++ language; they are nothing more than a simple text-replacement system intended to simplify your coding. Macros do not adhere to C++ type safety and cannot be debugged because macros are preprocessed, prior to compilation. Your compiler can only see the preprocessed code, not the original source code, and therefore cannot debug macros because the macros no longer exist at that point.

Inline functions are functions that can be debugged like any other function, but the compiler is able to eliminate the overhead of function calla by replacing those calls with inline expanded code. This is not unlike a macro, which is by definition inline expanded, but retains the built-in type safety and debugging capabilities of the C++ language itself.

Typically, if you can use an inline function (or C++ is general) then that is always the preferred option. But if a macro can achieve more than can be achieved with C++ alone, or can otherwise simplify the equivalent C++ code, then use a macro. Just keep in mind that macros are not type-safe and cannot be debugged by the C++ compiler.

Why timers are used?

If you need to get something done at certain time or periodically.

What plays an important role in transforming data into useful information?

Data and information are really just the same thing. However data is often an abstraction, especially digital data, where real-world objects are transformed into abstract representations that we interpret as numbers. Translating this abstract data to and from real-world information is typically achieved through software.

What is the difference between a repeat until and a while do loop?

Repeat until loops run until a condition is true. They repeat at the end of the loop and they will always run at least once.

While do loops will only run while a condition is true. They may not run at all.

Three programming languages?

1GL or first-generation language was (and still is) machine language or the level of instructions and data that the processor is actually given to work on (which in conventional computers is a string of 0s and 1s). 2GL or second-generation language is assembler (sometimes called "assembly") language. A typical 2GL instruction looks like this: ADD 12,8 An assembler converts the assembler language statements into machine language. 3GL or third-generation language is a "high-level" programming language, such as PL/I, C, or Java. Java language statements look like this: public boolean handleEvent (Event evt) { switch (evt.id) { case Event.ACTION_EVENT: { if ("Try me" .equald(evt.arg)) { A compiler converts the statements of a specific high-level programming language into machine language. (In the case of Java, the output is called bytecode, which is converted into appropriate machine language by a Java virtual machine that runs as part of an operating system platform.) A 3GL language requires a considerable amount of programming knowledge. 4GLor fourth-generation language is designed to be closer to natural language than a 3GL language. Languages for accessing databases are often described as 4GLs. A 4GL language statement might look like this: EXTRACT ALL CUSTOMERS WHERE "PREVIOUS PURCHASES" TOTAL MORE THAN $1000 5GL or fifth-generation language is programming that uses a visual or graphical development interface to create source language that is usually compiled with a 3GL or 4GL language compiler. Microsoft, Borland, IBM, and other companies make 5GL visual programming products for developing applications in Java, for example. Visual programming allows you to easily envision object-oriented programming class hierarchies and drag icons to assemble program components.

What are the uses of macros?

With macros, you can perform long or boring tasks just by a single click or keystroke combination. Also, you would not need to repeat the same action over and over again.

How do you use fseek function in c?

Answer

First a few points.

I do not know if you intended it but you are asking this of a C++ expert not a C expert. I mention this as fseek forms part of the standard C library file operations. Of course the C++ standard library inherits these functions, but they are not directly compatible with C++ IOStreams. You therefore have to have opened the file using the C fopen function, and close it using the C fclose function.

Next, you have to be careful when using fseek with text files. Things like end of line character sequences and the size of characters used can make a difference to the position values you need to pass to fseek via its offset parameter. The fseek function positions to the requested byte position within the referenced file, it knows and cares nothing about characters or their encoding making up the data of the file.

You also have all that silliness to do with character 26 (ctrl-Z) being interpreted as end of file in text mode - a Microsoft hangover from the days of MS-DOS. Then there is the effect caused by skipping over the byte order mark (if there is one), which as far as I know has to do with text files of characters in various Unicode encodings (so hopefully can be ignored in simple cases). See http://unicode.org/unicode/faq/utf_bom.html#BOM for more information on byte order marks.

You ask about positioning to the letter positions. Not all characters are letters and not all characters are printable. As I said fseek knows and cares nothing about the data or meaning of the values in a file and therefore cannot tell a letter from any other character type.

So assuming you meant characters when you mention letters in your question and assuming characters are all the same size and are byte sized then to position to the 45th character when starting with the file pointer positioned at the 20th character you can do the following:

status = fseek( file, 44L, SEEK_SET );

The fseek call shown above assumes file is a FILE * pointing to a valid open FILE structure. 44L specifies the position as a long integer constant, SEEK_SET is a value indicating that 44L is used to specify the position counting from the beginning of the file. As the beginning of the file is at position 0 and not position 1 we have to subtract 1 from the byte number we want if we count the first character as character 1.

The status variable is an int and is used to hold the returned value which is 0 on success and some non-zero value if fseek failed. If fseek fails you should check errno for more details or call a function such as perror as in the MSDN example, which converts the errno value to a string, prefixes the passed text and displays it on stderr (as associated with std::cerr in C++).

Alternatively you could specify the position to move to relative to the current position which would be the value given by the difference between the new position from the current position, thus 45-20 = 25:

status = fseek( file, 25L, SEEK_CUR );

Here the way the position value is interpreted is specified as SEEK_CUR, meaning to count from the current file position. This assumes of course that the file pointer position is in fact at position 19 (i.e. the 20th byte counting from 0) to start with. If it were at (say) position 112 then it would end up at position 137.

The reverse would be either:

status = fseek( file, 19L, SEEK_SET );

That is move to position 20 as counted from 0, the beginning of the file.

Or:

status = fseek( file, -25L, SEEK_CUR );

Which means move to the current position less 25, which assuming the file pointer is positioned at position 44 (i.e. byte 45 counted from 0) to start with would position it to position (44-25) = 19 (i.e. byte 20 counted from 0).

If you look carefully at the signature for fseek then you would notice that the offset parameter is specified as a long value - that is it is a signed value and so can be negative.

I should note that we could also position relative to the end of the file by specifying SEEK_END as the third parameter value. However this would mean we would need to know how long the file was in bytes so we can calculate the distance from the end of the file to the positions we require and so seems to be more effort than it is worth in this case.

Hope this helps. If you require further information then please ask another question.

What is the critical distintion between throwaway and evolutionary prototyping?

In throwaway prototype model we discard the prototype and start from scratch. In evolutionary prototype model we make changes in the prototype and refine it.

Why a hacker would break in to a computer?

a hacker is an intelligent person who an expert on programming languages and computer systems. Hackers enjoy breaking into computer systems and gaining unauthorized access to private networks for fun. They do not have evil intentions. They are copying data from your computer system and are less harmful whereas crackers are people who gets unauthorized access to an individual or organisation' s computer system to cause harm..

How many copies of the Common Language Runtime CLR can be executing on a machine?

As many as required by the programs that require a specific version, up the maximum of 4 different version. DotNet v1.0 programs require CLR v1.0. DotNet v1.1 requires CLR v1.1. DotNet 2.0, 3.0 and 3.5 require CLR v2.0 and DotNet v4.0 and 4.5 require CLR v4.0.

What is the advantage of doubly linked list over Doubly linked list?

A doubly linked list can be traversed in both directions (forward and backward). A singly linked list can only be traversed in one direction.

A node on a doubly linked list may be deleted with little trouble, since we have pointers to the previous and next nodes. A node on a singly linked list cannot be removed unless we have the pointer to its predecessor. On the flip side however, a doubly linked list needs more operations while inserting or deleting and it needs more space (to store the extra pointer).

What is the difference between stack and array?

Briefly, there are two main differences between an array and a stack. Firstly, an array can be multi-dimensional, while a stack is strictly one-dimensional. Secondly, an array allows direct access to any of its elements, whereas with a stack, only the 'top' element is directly accessible; to access other elements of a stack, you must go through them in order, until you get to the one you want. I hope this answered your question.

OK?

What are disadvantages of a linked list over an array?

A linked list is better bcoz:

1. A linked list can be grown to any size whereas a statically allocated array is of a fixed size and hence can cause problems if you try to insert beyond that.

2. Deletion of elements is a problem in arrays. You either have to move all the elements following the deleted element forward which is a waste of time or you have to place a sentinel indicating that the element in that position is deleted which causes a waste of space.

On the flip side, arrays are easier to handle because their memory allocation is done once and for all(atleast till you need more space and have to reallocate) and because there is no hassle with pointers.

What is a hover?

To "hover over"

To "hover over" is to excessively manage another person's efforts, or to remain physically inside the appropriate perimeter during an activity. This term is often used about a mother's behavior with her child and is usually pejorative.
Moving the mouse over an object; moving the mouse on and off an object.

What is the c program to find the octal equivalent of an integer?

void Decimal_to_Octal()
{
int n,r[10],i;
cout<<"Enter a number to find it's octal equivalent";
cin>>n;
cout<<"The octal equivalent of "<for(i=0;n!=0;i++)
{
r[i]=n%8;
n=n/8;
}
i--;
for(;i>=0;i--)
cout<count<}

What are the benefits of using functions?

A static function in class scope (within a class) can access only static class members (for all instances of the class).  A static function in file scope (not within a class) is visible only to code within that compilation unit, i.e. it cannot be linked from file to file.

Why must programs written in a high level language be translated into machine language before they can be run?

<p>You may know, in early days when there was no memory, once the program was written, they(computer scientists) fed input to the machine using switches and levers. That is , there is no interface between human and a computer. In this case , only people who were scientists,researchers could operate the computers. It was not possible for a common man to know about it. Also , its very hard to learn,understand,handle those machine ,even to people who are scientist etc.

As there was no memory, they had to fed the same intruction( thru switches and levers) whenever they need to solve the same problem.After the memory was found, the programs were stored in the memory(physical memory of the machine or like RAM), and were executed. At this times, older input techinques were modified according to it. Later assembly language( Mnemonics ) were used write instructions and these instructions were then translated into voltages (machine level code). Here, The technique Abstraction was used to cover the complexity of interacting with hardware. Even though it made work easier than before. It was too somewhat difficult to write programs in assembly language since the commands are difficult to remember. Also , each processor had its own assembly language. So that program written for one processor could not be used in another. This increased the difficulty to remember commands for different machines. Also, a program called "assembler" that translates assembly language to machine code also differed from machine to machine. On those days, writing assemblers was a nightmare and was badly difficult to design and implement. In assembly language only one instruction took chance to be translated and executed. So, it consumed more time to execute a program. All these drawbacks stimulated computer scientists to think for the alternatives. On each stage of this improvement, inventions in physics,electronics, mathematics were also made to improve the components of the machine. These technological improvements also increased the neccessity to replace the older techniques.

This is like two persons who know different languages, are trying to communicate each other.<p>

<p>

Later, high level languages were found so that its commands are in simple english words and can be remembered easily. It completely vanished the direct interaction with the hardware components. Its corresponding interface program is Interpreters/compilers( which is also a program) that translates the high level programs to the machine level code.

<p>

From the above discussion its clear that , in order to reduce the difficulties in communicating with the machine, one/more layer/s of abstraction is/are needed. That is, an intermediator is created and behaves as an interface between the programmer/user and the machine. This facilitates the programmer/user to interact with the machine and vice versa.So, Intended task is completed reliably and easily.

for example, its like a communication: English Speaker <--> Translator <--> French Speaker.

Also code written in High level language is optimized so that it keeps the size of the machine code small.

You can dig more under the titles : Compiler Design , The principles of programming languages.

Hope You got it.