answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

How does the Java programming language work?

Java uses a code-compiler, which does not create a machine-code, like normal Windows programs, but a byte-code, which the Java interpreter runs. It is like a mini-operating system, forming a layer between the operating system and the program code. This way, you can run Java programs on almost any platform. Main drawback is, that Java is slower than other languages. Consider using an other, platform dependent solution, if cross platform compatibility is not needed.

What is the answer to...Convert the binary number 10110101110112 to the equivalent decimal number?

The break down of 101101 = 100000 + 1000 + 100 + 1

100000(2) = 32(10)

1000(2) = 8(10)

100(2) = 4(10)

1(2) = 1(10)

32 + 8 + 4 + 1 = 45

What is the relation between a thread and a process?

Threads exist within the same process; they can share memory and take less time to perform a "context switch;" they are part of the same program running in parallel processing units. Threads each have their own dedicated memory, and a shared memory area. Processes are entirely partitioned units of executing code. They cannot directly share memory with each other without assistance from the operating system, and are protected from each other by the operating system (in most modern operating systems, that is). They require more time to perform a context switch, as the entire task must be swapped out of the CPU instead of just the thread stack.

Example problem using nested if statement in C programming?

if (i<0) if (j<0) printf ("i<0 and j<0");

else printf ("What's now? Where this else belongs to? It's i>=0 or i<0 and j>=0?");

The answer is:

if (i<0) if (j<0) printf ("i<0 and j<0");

else printf ("i<0 and j>=0");

Of course you can use brackets:

if (i<0) {

if (j<0) printf ("i<0 and j<0");

else printf ("i<0 and j>=0");

}

or

if (i<0) {

if (j<0) printf ("i<0 and j<0");

} else printf ("i>=0");

Explain what the term 'data' means?

Data, in the Scientific Method, means a record of the progress of your experiment. Data is whatever you observe about your experiment that may or may not change during the time of the experiment.

Who developed QBASIC programming language?

The 2 professors who developed QBACIS were Jhon G.Kemeny and Thomas E.Kurtz.

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.