answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What are the uses of array?

Array in most programming langauges like C ,C++, Java etc is a static , homogeneous and linear data structure. A data structure itself is a mathematical and logical model to organise data.It clearly specifies the domain of the data that can be stored in the structure and the collection of valid operations (functions) that can be performed on that data. Array is a linear structure in the sense that the data is organised sequentially(one after another in a contineous chunck of memory). It is a homogeneous data structure i.e. it contains elements which are of the same data type.The data type of array can be inbuilt like int , float ,char, double and even user defined that is created using a structure or a class. The main use of an array is to oragnise homogeneous data together as a group to perform operations on data in a collective manner since traversal and retrieval becomes easy.Whenever a homogeneous list(One Dimendional or Multi-Dimensional)has to be implemented we make use of array.The advantage of array lies in the fact that it uses indexed represenattion enabling us to access any member element directly. The example of practical use of array in progarmming will be creation of index lists, pointer arrays,matrix operations(transpose,addition ,subtraction,multiplication,inverse etc.).

Best first search program in c?

The best search programs to attempt writing in C are the following: Linear search (simplest), Binary search (faster) Hash search (fastest).

How do you use pervasive in a sentence?

Spring has pervaded the air.

you may use pervaded in your sentence.

How many 3-digit numbers can be formed using the digit 123456 and 7 if no digit can be repeated in number?

With questions like these it is often difficult to remember whether we are looking for permutations or combinations. In English we use these two terms interchangeably but in mathematics we must be more precise. The way to remember is that if the order matters, then position matters, thus position = permutation. If order does not matter then we're looking for combinations. Put simply, 123 and 321 are the same combination but different permutations. In this case we're looking for permutations (thus combination locks should really be called permutation locks).

The formula for calculating permutations is fairly simple: given 7 digits from which we must select 3, we have 7^3 = 7 x 7 x 7 = 343 permutations in total. However, in order to exclude repeated digits we must use a different formula. When we select the first digit we have 7 choices (just as we do with repetition allowed), but when we choose the next digit we only have 6 choices remaining and for the final digit we only have 5 choices remaining.

To express this more mathematically, we need to use factorials. Factorial 7 (written 7!) is 7 x 6 x 5 x 4 x 3 x 2 x 1 = 5040. This tells us there are 5040 different ways we can write all the digits from 1 to 7 without repetition. In order to calculate all the 3-digit permutations we need to stop multiplying when we reach 4. To achieve this, we use the following formula:

n! / (n-m)!

where n is the number of elements in the set and m is the number of elements we wish to select.

Thus we get:

7! / (7-3)! = 7! / 4!

If we (partially) expand this we find we have:

7 x 6 x 5 x 4! / 4!

The 4!s above and below the division will cancel each other out, so we get:

7 x 6 x 5 = 210 permutations without repetition.

If we were to fully expand this out we find we have:

(7 x 6 x 5 x 4 x 3 x 2 x 1) / (4 x 3 x 2 x 1) = 5040 / 24 = 210 permutations without repetition.

Note that if we were only interested in the number of combinations (without repetition), we divide the number of permutations by 3! For that we use the following formula instead:

n! / (m! x (n-m)!)

Thus we'd get:

7! / (3! x 4!) = (7 x 6 x 5 x 4!) / (3 x 2 x 1 x 4!)

The 4!s cancel each other out so we get:

(7 x 6 x 5) / (3 x 2 x 1) = 210 / 6 = 35 combinations without repetition.

How do I read a memory address with borland c?

In order to read a memory address you must hold a reference to that address. If the object at that address is a named object, then the object's name is a reference, thus we can simply take its address using the address-of operator (unary &):

int i = 42;

printf ("Variable i resides at memory address 0x%x\n", &i);

If we wish to store the address we must use a pointer variable of the appropriate type:

int* p = %i;

Like any other variable, a pointer variable has an address of its own, thus we can read its address:

printf ("Variable p resides at memory address 0x%x\n", &p);

To read the address being pointed at we simply examine the pointer's value:

printf ("Variable p refers to memory address 0x%x\n", p);

Note this address is the same as the address of i, the object being referred to (pointed at).

To read the value stored at the address being pointed at we must dereference the pointer (unary *). Dereferencing is also known as indirection because we are indirectly accessing the object's value:

printf ("Variable p refers to the value %d\n", *p); // e.g., 42

Pointers can refer to both named and anonymous objects. Anonymous objects are simply objects allocated on the heap at runtime. Since they don't exist at compile time we cannot name them:

int* anon = malloc (sizeof (int)); // allocate memory

Note that anon is the name of the pointer, not the object being pointed at.

printf ("The anonymous variable resides at memory address 0x%x\n", anon);

free (anon); // always release heap allocations as soon as we are finished with them!

Pointers also make it possible to pass memory addresses to and from functions (also known as pass by reference):

void f (int* p) {

}

int a = 42;

f (&a); // pass the address of a to the f() function

Note that all variables in C are passed by value, but when we pass a pointer by value we are passing an address and an address is a reference. Passing references is useful when the object being referred to cannot be efficiently passed by value. Typically this means any value that is larger than the word value of the underlying architecture (e.g., 4 bytes on a 32-bit system). Arrays in particular are never passed by value, hence an array implicitly converts to a pointer.

What is throwaway prototyping?

A prototype is typically build to better understand some aspect of the final project. If you don't intend to use any part of the prototype in the final produce, it can be said to be a throwaway.

What is the standard notation of 3.987654321E20?

The standard notation of 3.987654321E20 is 398,765,432,120,000,000,000

When was internet made?

A long time ago, about 1995 or so, when Al Gore made it

i say 1969...... that's what i heard

How to make subtitles?

the company uses word recognition and then it will feed it to the screen.

The first 640K of memory addresses?

The first 640K was only an issue with older MS-DOS based systems which limited memory to 1MB. The upper memory was reserved specifically for system use, leaving 640K available to the user (originally the limit was 512K). Extended and enhanced memory drivers allowed additional memory to be used above the 1MB barrier. These barriers no longer exist as memory is allocated virtually on all modern systems. To all intents and purposes, a 32-bit system has a full complement of 4GB of memory available even when it physically has less than 4GB installed. This is achieved by using disk space to swap the contents of memory in and out of RAM as required. A 64-bit system essentially has unlimited memory, only limited by the amount of available disk space. A single 64-bit system can address far more memory than physically exists in the world today.

What is a client station?

A client station is a place where computer users set up. This is based on the collection of IP addresses.

Compare break and continue statement?

Break - will force to terminate the loop you are in to the nearest outer block.

Continue - will force to skip the rest of the code in loop and take next iteration.

Break for example is not only limited to loop constructions, it is also used in switch statement in order to stop executing following cases (works as described above, jumps out of switch).

Write a shell program to display any number from 1 to 10 in words using case statements?

# #inlude int main()

{ unsigned short myNumber = 1; do

{

cout << "Enter a number between 1 and 10: ";

cin >> myNumber;

} while ((myNumber <= 1) && (myNumber >= 10)); switch (myNumber)

{

case 1:

cout << "You've entered one.\n"; break;

case 2:

cout << "You've entered two.\n"; break;

// And so on

case 10: cout << "You've entered ten.\n";

break;

} cin.get();

cin.get(); return 0;

}

How do you make an o with a line going through it on the keyboard?

Hold down the Alt key and type 148

ö

Well, I looked through over the Character Map in order to find it.

Just use the following shortcut keys to produce this character, one for the upper case, one for the lower case of the character:

Alt + 0214 Ö

Alt + 0246 ö

Note: when performing shortcuts, you must press & hold all the keys in the shortcut altogether....

How do you use malloc and calloc to allocate memory for 100 integers?

int *p, *q;

p = (int*) malloc (100 * sizeof (int));

q = (int*) calloc (100, sizeof (int));

Note that p is left in an uninitialised state whereas q is initialised with the value zero.