answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Find the missing number 6 3 9 12 21 54 87?

The next number in the sequence is 9. The rule is to add 2, then subtract 1, add 2, subtract 1, and so on.

Why is C plus plus such a robust programming language?

Borland's implementation of C++ was never regarded as the Bible of Computer Programming (whatever that means). If it were we'd probably still be using it today, but it was rendered obsolete in 1997 when Borland C++ Builder superseded it.

How many operators in c?

Quite a few. Some of them are:

, () [] & * . ->

+ ++ += - -- -=

* / % *= /= %=

! == <= >= < > !=

<< >> >>= <<=

& | ^ ~

&&

What are the disadvanteges of high level programming language?

Depends on the purpose of the program your creating. Generally speaking high level languages require far more system resources than low level languages. So if you were writing embedded code on a microcontroller, writing in Java would be a big no no as you'd barely be able to do anything whereas in C or assembler you could write a functional and useful program. (C is often used for faster development and high accuracy whereas assembler can be moulded to high performance low accuracy).

Can a queue be represented by a circular linked list with only one pointer pointing to the tail of the queue?

Yes.

With a linked list, each node in the list points to the next node, except the tail which points to nothing. To maintain the list we must keep track of the head node at all times. In order that all insertions and extractions occur in constant time, all insertions and extractions must occur at the head. Thus when we insert a new node, it simply points to the head and then becomes the head. And to extract the head, the next node from the head becomes the head before we delete the old head. Since all insertions and extractions occur at the head, linked lists can be used to implement a stack (last in, first out). We can also traverse the list from the head and insert at any point in the list in order to maintain a sorted order, however this cannot be done in constant time and there are more efficient ways of maintaining order than by a linked list.

In order to implement a queue (first in, first out) using a linked list, we need to maintain a pointer to the tail as well as the head. Extractions still occur at the head, as before but insertions now occur at the tail, where the tail points to the new node which then becomes the tail. However, rather than maintaining a separate pointer for the head, we can simply point the tail at the head, thus creating a circular linked list. Since the tail always points at the head we have constant time access to both through a single pointer. Insertions are only slightly more complicated in that new nodes must first point at the head node (which they can copy from the tail node) before the tail node points to the new node which then becomes the tail.

Which part of a machine language instruction specifies data on which an operation acts?

False, Op code specifies the operation to perform, the operand specifies the data.

Compare oodbms with rdbms?

The differences between the three approaches Table 1: A Comparison of Database Management Systems Criteria RDBMS ODBMS ORDBMS Defining standard SQL2 ODMG-2.0 SQL3 (in process) Support for object-oriented features Does not support; It is difficult to map program object to the database Supports extensively Limited support; mostly to new data types Usage Easy to use OK for programmers; some SQL access for end users Easy to use except for some extensions Support for complex relationships Does not support abstract datatypes Supports a wide variety of datatypes and data with complex inter-relationships Supports Abstract datatypes and complex relationships Performance Very good performance Relatively less performance Expected to perform very well Product maturity Relatively old and so very mature This concept is few years old and so relatively mature Still in development stage so immature. The use of SQL Extensive supports SQL OQL is similar to SQL, but with additional features like Complex objects and object-oriented features. SQL3 is being developed with OO features incorporated in it Advantages Its dependence on SQL, relatively simple query optimization hence good performance It can handle all types of complex applications, reusability of code, less coding Ability to query complex applications and ability to handle large and complex applications Disadvantages Inability to handle complex applications Low performance due to complex query optimization, inability to support large-scale systems Low performance in web applications Support from vendors It is considered to be highly successful so the market size is very large but many vendors are moving towards ORDBMS Presently lacking vendor support due to vast size of RDBMS market All major RDBMS vendors are after this so has very good future

What software is used to create art?

A variety of applications can be used in the software development process. The following are a list of different types of applications and some examples:

IDE: Codeblocks, NetBeans, Eclipse, Visual Studio, Stylus Studio, XMLSpy.

Documentation and design: Office

Other editors: UltraEdit, Notepad, Wordpad

Code storage: CVS, VSS, SVN

Databases: MSSQL, Oracle, MYSQL

Secondary:

Browsers: IE, Firefox, Chrome

OS: Windows, Linux

Drivers: Graphics driver, mouse driver, keyboard driver.

How do you script in roblox?

Scripting on Roblox is done using a programming language called Lua. There is a guide for it in wiki.roblox.com

EDIT: not a good one though. Try the scripting helpers forum if you need help beyond the wiki.

How are Structure passing and returning implemented by the complier?

When structures are passed as arguments to functions, the entire structure is typically pushed on the stack, using as many words as are required. (Programmers often choose to use pointers to structures instead, precisely to avoid this overhead.) Some compilers merely pass a pointer to the structure, though they may have to make a local copy to preserve pass-by-value semantics. Structures are often returned from functions in a location pointed to by an extra, compiler-supplied ``hidden'' argument to the function. Some older compilers used a special, static location for structure returns, although this made structure-valued functions non-reentrant, which ANSI C disallows

Why do you use inverted commas?

The inverted comma " " , is normally used to show what a person has said or is saying verbatim and not as reported speech.

Inverted commas are normally used it books to show when a person is speaking, this separates it from the narration of the story line.

For example:

John shouted to James "Come here quickly".

Paraphrased it would be,

John shouted to James to come quickly.

What makes windows os event driven?

Event driven application is a event happening in the operating system, when you click a button it makes an event, also a timer is a event, timers can be used in screen savers, after a certain amount of minutes, the timer will run out and the event for the screen saver to appear will happen :)

Hope i helped

How many program development cycle steps are repeated until no errors can be found in the program?

As many as can be squeezed out of the development budget. Deadlines can be pushed beyond the limit but budgets can only be pushed so far. If developers were forced to release 100% bug-free programs, nothing would ever be released on time let alone within budget. As soon as it's fit for purpose you have to ship, even if that means dropping problematic features -- you can always deal with them later.

Essential condition for pure object oriented language?

Mainly no primitive types such as int, char, bool, etc.

Java could be considered if it hadn't this primitive types.

Does computer programming have its own degree or do you need to major in computer science?

There are Associated Degree (U.S.A.) and Professional Certification available for Computer programming. But you don't need to have one to be a programmer, and have any of those (AA degree or certification) does not mean that you can or should program, either!!

Computer Science major is NOT the only way to learn computer programming. There should be courses available for non-computer science majors.

What is a quick sort?

Quicksort is a recursive algorithm.

Given an array and indices to the lower and upper bounds of a subset within the array, divide the subset into two subsets around a pivot value then recursively apply the algorithm to each of these subsets until a subset has fewer than 2 elements.

The algorithm begins by checking the size of the given subset. If there are fewer than 2 elements then the subset is sorted. This represents the end condition for this instance of the algorithm since a subset of 0 or 1 elements can always be regarded as being sorted.

If the set has 2 or more elements, however, a pivot element is selected . the pivot is typically the mode of the first, last and middle elements. The pivot is then swapped with the last element so it's out of the way.

Two indices are then instantiated, left and right, one referring to the first element (the lower bound), the other referring to the penultimate element (we ignore the pivot at the end for now).

While the left index is less than the right index, repeat:

1. While left is less than right and the value referred to by left is less than the pivot, increment left. (In other words, search for the first value from the left but no further than the right that is not less than the pivot).

2. While right is greater than left and the value referred to by right is not less than the pivot, decrement right. (In other words, search for the first value from the right but no further than the left index that is less than the pivot).

3. If the left and right indices are not equal, swap the values at those indices.

When the indexes are the same, or left crosses right, the loop ends.

Swap the value at the left index with the last element (the pivot).

At this point, the pivot is now in place and all values less than the pivot are to its left, with all others to its right. The values on either side are not yet sorted, thus we recursively invoke the same algorithm to sort each of these two subsets (excluding the pivot, of course).

Since the set is divided into two smaller subsets upon each invocation of the algorithm, each recursion takes less time because there are fewer elements to divide. The recursions effectively form a binary tree with one recursion per node. Some nodes will terminate earlier than others so the tree will probably be unbalanced. But since the sorting is done in-place, each recursion will unwind automatically leaving behind a sorted subset within the set. When the initial instance of the algorithm terminates, the entire set is sorted.

Menu driven program for selection sort bubble sort and insertion sort in c?

#include<iostream>

#include<time.h>

#include<iomanip>

#include<string>

void swap(int& x, int& y)

{

x^=y^=x^=y;

}

void bubble_sort(int* A, int size)

{

while(size)

{

int n=0;

for(int i=1; i<size; ++i)

{

if(A[i-1]>A[i])

{

swap(A[i-1], A[i]);

n=i;

}

}

size=n;

}

}

void insertion_sort(int* A, int size)

{

for(int i=1; i<size; ++i)

{

int value=A[i];

int hole=i;

while( hole && value<A[hole-1] )

{

A[hole]=A[hole-1];

--hole;

}

A[hole]=value;

}

}

void selection_sort(int* A, int size)

{

for(int i=0; i<size-1; ++i)

{

int j=i;

for(int k=i+1; k<size; ++k)

if(A[k]<A[j])

j=k;

if( i!=j )

swap(A[i],A[j]);

}

}

void sort(int* A, int size, int sort_type)

{

switch(sort_type)

{

case(0): bubble_sort( A, size );

case(1): insertion_sort( A, size );

case(2): selection_sort( A, size );

}

}

int* copy_array(int* A, int size)

{

int* copy=new int[size];

memcpy(copy, A, size*sizeof(int));

return(copy);

}

void print_array(int* A, int size, char* prompt)

{

std::cout<<prompt<<"\t";

for(int i=0; i<size; ++i)

std::cout<<std::setw(2)<<A[i]<<" ";

std::cout<<std::endl;

}

int get_rand(int range_min=0, int range_max=RAND_MAX)

{

return((int) ((double)rand() / (RAND_MAX + 1) * ((range_max + 1) - range_min) + range_min));

}

int input_char(std::string prompt, std::string input)

{

char ch;

do

{

std::cout<<prompt<<": ";

std::cin>>ch;

}

while(input.find(ch)==std::string::npos);

return(input.find(ch)%(input.size()/2));

}

int main()

{

srand((unsigned) time(NULL));

int size = get_rand( 10, 80);

if( int* A = new int[size] )

{

for( int i=0; i<size; ++i )

A[i]=get_rand( 1, size );

int choice=input_char("Please select a sorting method:\n[B]ubble, [I]nsert, [S]election", "bisBIS");

std::cout<<"You chose ";

switch(choice)

{

case(0): std::cout<<"bubble"; break;

case(1): std::cout<<"insertion"; break;

case(2): std::cout<<"selection"; break;

}

std::cout<<" sort...\n"<<std::endl;

print_array( A, size, "Before sorting" );

sort(A, size, choice);

print_array( A, size, "After sorting" );

delete [] A;

}

return(0);

}

What is the objective of a structured walkthrough?

The advantage of using a structured approach is that the work and information will remain structured. The information will be stored in such an organized manner there will be little room for mistakes.

Can a Structure contain a Pointer to itself?

Yes, it is quite common.

Example:

struct List {

struct List *Next;

int value;

}

typedef struct List List;

Example2:

typedef struct Tree Tree;

struct Tree {

Tree *left,*right;

int value;

};

How do you decompile a compiled program?

Basically, you can't. It would be like trying to take a baked cake and turn it back into its ingredients. It is maybe not that severe, but nevertheless very difficult to break a program and find some of its original components. That is why we keep the programs themselves in the form of source code.

But for some technologies it is possible. For example .Net programs can be decompiled.

And there are special tools which allow to do that - .net decompilers.

For an example look at the one at the related link below.

How do you write a program in Python to find the first n prime numbers?

One way to do this is to write a function that checks if a number is prime:

def isPrime(number):

for i in range(2, number):

if number%i == 0:

return False

return True

Then create variables to track how many primes have been found and a variable to track which number is being tested for being prime. Increment that variable and test it, and if it is prime print it out (or save it somewhere) and increment the variable being used to track how many primes have been found:

targetPrimes = 10 #number of primes to find

primesFound = 0 #number of primes found

i = 1

while (primesFound < targetPrimes):

i += 1 #first number tested is 2

if isPrime(i):

print(i)

primesFound += 1

What are the different types of technology available for inputting formatting and editing text?

keyboard scanner word prosseser and to give copies to printer The standard technology to use for input of text is a keyboard and more recently, a scanner. The keys are depressed on the keyboard and whatever the user depresses is transferred to the word processor, built into the office application in use. Using a scanner enables one to manipulate text after converting it from jpeg to Word. A scanner can also save in PDF format and there are programs to convert this to Word as well.

What is a criminal hacker?

Originally the term referred to people who used a razor blade and/or fingernail clippers to "hack" or roughly cut parts in electronics such as the traces on circuit boards, legs of diodes etc. Police scanners were "hacked" in order to add more memory, remove CPU processors , speed up scanning by "hacking" the crystal oscillator and replacing with faster ones. Thes methods are directly related to why computers now have more RAM, and are faster. Some of the old (and I do mean old) "hackers" devised a system in the 1960s to simultaneously send voice and data over a phone line using frequency phase shifting and filtering. A similar process used later by DSL.

"Hacking" and "Modding" evolved into things such as examining the programming of a thing. Beginning with noticing things such that by pressing certain keys or combinations of keys in certain secquences on a device could produce certain results. Following the era of IBM's "Big Blue" chess tournament, AT&T introduced the "unbeatable Tic Tac Toe Computer, and exhibited it. I, I mean a "hacker" back then, was able to beat the computer with a sequence of key presses in order to "cheat" the computer out of a move. On many Shortwave radios, Police Scanners, even cell phones etc, certain key presses are used in the programming, and could be used to alter that programming.

The keys on a keyboard of a device are a "Matrix" Keyboards use a matrix with the rows and columns made up of wires. Each key acts like a switch. When a key is pressed, a column wire makes contact with a row wire and completes a circuit. The keyboard controller detects this closed circuit and registers it as a key press to the software.

I'm going to try to keep this understandable to readers ...

Software can emulate or act like hardware.

Example: a hardware modem versus a DSP/Digital Signal Processor modem, where a chip is programmed to act like the hardware....

So, later, the focus turned even more from "hacking" the actual electronics and hardware to software "hacking" through PROGRAMMING.

A "black hat" hacker is often referred to as a microcomputer user who attempts to gain unauthorized access to proprietary computer systems. Although that could be a "cracker" ... a person cracking passwords etc.

Most often people who call themselves "hackers" are called "wannabes" by the old-timers, and nowadays are often adolescents using a program they didn't write, by clicking a button they didn't create, to do what don't understand, in an attempt to disrupt something they don't know how to fix.

"White Hat" hackers are the "good guys" like ... Like the old-timers who vastly improved what computers are capable of doing, and the ones currently trying to improve security by locating and preventing weaknesses.

This Answer is dedicated to the memory of Bill Cheek, author, The Scanner Modification Handbook series, and his BBS and Fidonet terminal (prior to "The Internet") Good man, Good freind to many... May he R.I.P.