answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Who invented a calculating machine?

The very first calculating "machine" was human hands and fingers.

The abacus was next in about 300 BC.

Can a thread create a process?

No, a thread can't create aprocess, because the environment of the thread is a part of a process which created this thread.

Which book is best for software programming?

There is no single book that is best for programming. There are many programming languages and each will have one or more recommended books associated with it. For instance, C++ programmers will typically own "The C++ Programming Language" and "Programming: Principles and Practice Using C++", amongst many others. Programmers will also own text books related to more specific type of programming, such as multimedia/games programming, financial programming, scientific programming, and so on. In short, you cannot rely on just one book to teach you everything you need to know.

Where does the main function starts and end in c program?

The entry point of a C program is the main function.

The function signature might be like one of these:

1. int main (void)

2. int main (int argc, char *argv[])

Definition of memory and its types?

Memory refers to the physical devices used to store programs (sequences of instructions) or data (e.g. program state information) on a temporary or permanent basis for use in a computer or other digital electronic device. Computer Memory is two types as Primary Memory and Secondary Memory at the base of uses. The term primary memory is used for the information in physical systems which function at high-speed (i.e. RAM), as a distinction from secondary memory, which are physical devices for program and data storage which are slow to access but offer higher memory capacity. When data of Primary Memory stored on secondary memory is called "virtual memory".

Primary Memory

The term "memory" is often (but not always) associated with addressable semiconductor memory, i.e. integrated circuits consisting of silicon-based transistors and used as primary memory. Primary storage (or main memory or internal memory), often referred to simply as memory, is the only one directly accessible to the CPU. The CPU continuously reads instructions stored there and executes them as required. Any data actively operated on is also stored there in uniform manner. RAM used for primary storage is also volatile, i.e. they lose the information when not powered). Cash Memory is also a super fast then RAM and it working for only processor.

There are two main types of semiconductor memory: volatile and non-volatile.

Examples of non-volatile memory are flash memory (sometimes used as secondary, sometimes primary computer memory) and ROM/PROM/EPROM/EEPROM memory (used for firmware such as boot programs). Examples of volatile memory are primary memory (typically dynamic RAM, DRAM), and fast CPU cache memory (typically static RAM, SRAM, which is fast but energy-consuming and offer lower memory capacity per area unit than DRAM).

Secondary Memory

The term "storage" is often (but not always) used in separate computers of traditional secondary memory such as tape, magnetic disks and optical discs (CD-ROM and DVD-ROM). Secondary storage (also known as external memory or auxiliary storage), differs from primary storage in that it is not directly accessible by the CPU. The computer usually uses its input/output channels to access secondary storage and transfers the desired data using intermediate area in primary storage. Secondary storage does not lose the data when the device is powered down-it is non-volatile. Hard disk, CD and DVD drives are usually used as secondary storage. Some other examples of secondary storage technologies are: flash memory (e.g. USB flash drives or keys), floppy disks, magnetic tape, paper tape, punched cards, standalone RAM disks, and Iomega Zip drives.

What is the use of namespace?

There are many situations when writing a computer program that requires one to make use of libraries provided by other people. Suppose that you have created a program to do matrix multiplication, and one of your functions inside this program is called multMatrix(a, b). Now suppose you are using a library provided by someone else (not necessarily for matrices), and quite by coincidence their library also contains a function called multMatrix(a, b) -- thus both of these functions have exactly the same signature. Which one should be used? Old-school programmers and librarians used to go through a lot of effort to try and establish function names that would be unique -- however, this did not always solve the problem. The use of name-spaces provides an adequate mechanism for avoiding these "name clashes". Functions (or methods) are now grouped into namespaces, and we are assured (to a certain point) that namespaces should be unique (for example if you use the name of the company you are working for as a namespace), now even if two functions have the same signature they should be located within different namespaces, allowing you to avoid name-clashes.

What is command line interface?

A CLI (command line interface) is a user interface to a computer's operating system or an application in which the user responds to a visual prompt by typing in a command on a specified line...

What are theApplications of stack in data structure?

1. Expression evaluation and syntax parsing

Calculators employing reverse Polish Notation use a stack structure to hold values. Expressions can be represented in prefix, post fix or infix notations. Conversion from one form of the expression to another form may be accomplished using a stack. Many compilers use a stack for parsing the syntax of expressions, program blocks etc. before translating into low level code. Most of the programming languages are context-free languages allowing them to be parsed with stack based machines.

2. Runtime memory management

A number of programming languages are stack oriented , meaning they define most basic operations (adding two numbers, printing a character) as taking their arguments from the stack, and placing any return values back on the stack. For example, Post Script has a return stack and an operand stack, and also has a graphics state stack and a dictionary stack.

3. Security

Some computing environments use stacks in ways that may make them vulnerable to security breaches and attacks. Programmers working in such environments must take special care to avoid the pitfalls of these implementations.

What language is used for robot programming?

A bot can be written in a server-side language like php, asp, etc.

How do you implement queue using singly linked list?

Queues are a first in first out structure (FIFO). This means all extractions occur at the head of the list and all insertions occur at the tail. This requires that you maintain pointers to the head and tail node to allow constant time insertion and extraction of nodes. The nodes themselves are singly linked, each pointing to the next node. The tail node always points to NULL until a new node is insert, which the tail points to. The new node then becomes the tail. When extracting a head node, its next node (which may be NULL if it is also the last node) becomes the new head of the list. If the head is NULL, the tail is also set to NULL.

What are the characteristics of the bubble sort algorithm?

Bubble sort is a stable, in-place sort with a best, worst and average case of O(n!) for n elements, thus making it highly inefficient and entirely unsuitable for sorting large amounts of data. For this reason bubblesort is often cited as an example of how not to write an algorithm.

The algorithm starts by accepting a zero-based array with n elements (0 to n-1). While n is greater than 1, the algorithm iterates an outer loop. On each iteration of the outer loop, an inner loop traverses from element index 1 to n-1. On each iteration of the inner loop, the element at the current index is compared with the element at the previous index. If they are out of order, the two elements are swapped. When the inner loop has finished, n is decremented. At this point element n is now its correct place and is ignored on the next iteration of the outer loop. When n is not greater than 1, all the elements are sorted and the outer loop terminates.

In other words, the algorithm locates the largest value in the range 0 to n-1 and places it at index n-1 (bubbling it up the list with each swap). After decrementing n, everything from element n up is sorted and everything below n is unsorted, thus creating two subarrays split at n. On each pass, the sorted subarray gains a new element and the unsorted subarray loses an element. When there is only one element in the unsorted subarray, the entire array is sorted.

The inefficiency of the algorithm is that it takes no account of elements at the end of the unsorted subarray that may already be in their correct position. The algorithm can be improved with the observation that the position of the last swap at the end of the inner loop means that everything from that point forwards is already sorted and don't need to be compared on the next pass. So rather than reducing the unsorted subarray by just one element, the subarray can be reduce by one or more elements. To achieve this we initialise a temporary variable with the value zero at the start of the outer loop, and whenever a swap occurs in the inner loop we assign the current index to the temporary variable. When the inner loop ends, the temporary variable indicates where the last swap occured and we can assign that value to n, which may reduce n by one or more elements on each pass. The only other change we need to make is that the outer loop now terminates when n is zero (the initial value of the temporary variable), which means no swaps occured on the last iteration of the inner loop, so everything must be sorted.

Even with this optimisation the worst case is still O(n!) if the list is completely reversed. However, for an already-sorted list the best case becomes O(n). Since these two extremes are isolated cases, the average case is somewhere in between, around O(n!/2), which is still highly inefficient and unsuitable for large amounts of data.

The following is an implemention of an optimal bubble sort in C++:

template<typename _Ty>

void bubble (std::vector<_Ty>& A)

{

unsigned size = A.size();

while (size)

{

unsigned temp = 0; // records last swap position

for (unsigned index=1; index<size; ++index)

{

if (A[index]<A[index-1])

{

std::swap (A[index],A[index-1]);

temp=index;

}

}

size = temp;

}

}

How do you get a computer in stick RPG?

In stick RPG complete, get 500 intelligence, click on the car next to your house and click the key. press c to get in.

What is recursive algorithm?

Algorithm can be defined as an interpretable, finite set of instructions for dealing with contigencies and accompanying task that has recognizable end-points for given inputs. It is a tool for solving a well computational problem. A recursive algorithm is one which calls itself.

What is sixth generation in programming language?

There is no such thing. Until the introduction of third generation hardware, languages were never actually classified by generation. They were either low-level symbolic languages or high-level abstract languages and that hasn't changed to this day. The terms 3GL, 4GL and 5GL are nothing more than buzzwords adopted by the software industry for marketing purposes but they have no practical meaning as no such specification exists to define them.

Historically, the term 3GL arose after the introduction of third generation hardware. Thus all previous high-level languages became known as 2GL while assembler became 1GL. But it was all done reflexively as a result of market hype. Since then, we've seen 4GL and 5GL applied to programming languages but no-one can actually agree on what these terms really mean. They are marketing buzzwords, nothing more.

In some cases, 4GL and 5GL is nothing more than 3GL with some enhancement. In others, 4GL and 5GL are a completely new form of language altogether. Ultimately, comparing two 5GL languages is like comparing chalk with cheese. The term tells us nothing about the actual software.

Some attempts have been made to clearly define the difference between 4GL and 5GL. To some, a 4GL is a domain-specific language (DSL) while to others it is a subset of DSL. Meanwhile 5GL is generally regarded as being intended for artificial intelligence applications. However, just as with 1GL, these are merely reflexive definitions attempting to make sense of the meaningless. Unless the industry as a whole can formally agree upon what 6GL means, then it will be just as meaningless. All we can say for sure is that 6GL will follow 5GL. But that doesn't mean it is any better than 5GL, only that it is newer in some way.

How do you find a factorial using Unix?

perl -e 'sub f { my $fu = shift; return 1 if $fu == 1; return f($fu - 1) * $fu; } print f(5), "\n";'

just paste that in to a command prompt, change the print f(5) to print f(6) or whatever you want.

What is the major difference between c and c plus plus?

C is an imperative (procedural), structured paradigm language whereas C++ is multi-paradigm: procedural, functional, object-oriented and generic. Both are high-level, abstract languages. While C's design provides constructs that map efficiently to machine code instructions, C++ is more abstract, relying heavily upon object-oriented principals. However, both are equally capable of producing highly-efficient machine code programs. C++ derives almost directly from C thus everything you can do in C you can do in C++ with relatively minor alterations to the source. C++ was originally called C with Classes and that pretty much sums up the main difference between the two languages. However, there are many subtle differences.

One key difference between C and C++ is in the struct data type. In C, a struct can only contain public data members (with no methods). In C++, a struct is similar to a class, combining data and the methods that operate upon that data into a single entity (an object). The only difference between a C++ struct and a C++ class is that class members are private by default whereas struct members are public by default.

Another key difference is that because C++ is object oriented, there is much less reliance upon the programmer to manage memory. Each object takes care of its own memory allocations (including embedded objects), thus the programmer simply creates and destroys objects as needed. Thus C++ is much easier to work with, especially with regards to highly-complex hierarchical structures, but is every bit as efficient as C.

Both languages are highly popular and there are few architectures that do not implement suitable compilers for both. Thus they are both highly portable. However, the object oriented approach to programming gives C++ a major advantage over C in terms of code re-usability, scalability and robustness.

What are guided unguided media?

guided media is the transmission medium in which data/signal is guided by the cable or wire so used to a specific path. there are 4 types of guided media

--> open wire

-->twisted pair

--> co-axial cable

-->optical fibre

for more details open the link -----

http://www.techbooksforfree.com/intro_to_data_com/page37.html#37

What are all the variables?

There are 'constant variables' , 'independant variables' and 'dependent variables'

Constant Variable- things in the experimment that should be kept the same

Independant variables- something that can be varied in an experiment

Dependant variable- something that can be affected