answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Calloc allocates a block of memory for an array of elements of a certain size?

No. The calloc function allocates a block of memory for a count of a specific type. The size of the type is already known to the compiler so does not need to be specified, it will automatically multiply the type's size by the count. With malloc, you have to allocate memory in bytes, therefore you need to calculate exactly how many bytes you will need for a given type and the number of elements of that type.

Examples (allocate 100 integers):

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

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

Note also that malloc does not initialise the memory whereas calloc does (the allocated memory is initialised with the value zero). As such, malloc is more efficient when you want to initialise the memory by copying from other memory. That is, there's no point initialising memory you're going to initialise manually, so long as you don't access that memory before it is initialised.

When a computer's operating system is down does the computer run very slowly and inefficiently?

No. If the computer's operating system is down then the computer is also down. A computer requires a functional operating system of some kind. If there is no operating system at all, you must install one by booting the system from an operating system installation disc. This, in turn, loads a limited but temporary operating system sufficient to complete the installation. If there is an operating system but it is damaged to the point the computer will not boot at all, you must re-install the operating system. If the system fails to boot due to a driver issue, you must reinstall the faulty driver.

A system typically runs very slowly when the chipset driver is not installed. A generic driver will be installed instead, but this often leads to less than optimal performance as certain hardware features will not be available. Indeed, any major driver (graphics, audio, network, fixed-disk, SM bus, etc) that is replaced with a generic driver can lead to reduced performance.

Another common cause for reduced performance is incorrect hardware settings in the BIOS setup.

How does iris recognition work?

the disadvantages of iris recognition is that a person who has a colour blindness or who are blind cannot pass through this iris recognition test.the advantages is that iris is an unique organ which all the people possess.

Which member should be declared as static?

Members which are shared among all instances of a class should be static.

What is thread level parallelism?

If I know the answer then why I search for it on your site. you site developers are very bad. you only want that some one click on your site and start using some another thing at your site leaving his/her own work.. very bad

How can you create a program that asks the user for the number of miles driven and the gallons of gas used?

That depends on the language. In C++ you might use the following:

#include<iostream>

using namespace std;

int main()

{

int miles, gas;

cout<<"Input the number of miles driven: ";

cin>>miles;

cout<<"Input the gallons of gas used: ";

cin>>gas;

cout<<"MPG: "<<miles/gas<<endl;

}

Of course when extracting user input you must always test the input is valid before operating upon it. If the user enters 0 gallons then you will end up with a divide by zero error.

What are the disadvantages of Algol programming language?

"c is a mother language no dis advantage."

If there were no disadvantages to C, then C would be the only programming language!

C is not an object oriented language - to make it so, C++ was developed.

C is not a "strongly" typed language. Some might see this as an advantage (as there are times when this is highly beneficial). From a code maintenance standpoint this is a weakness. C also has been (especially in the early days) considered highly cryptic. To be fair, any programming language can be coded cryptically, it's just easier in C.

C requires something to be defined before it can be used. This is not an entirely bad thing as Best Design Practices calls for "Top-down" design with "bottom-up" implementation.

Can two different pointer variables point to the same memory location?

Yes, two different pointer variables may point to the same memory location. Two issues, though... If your code thinks the two pointers represent two different allocations of memory, then you risk deallocating one and not realizing that the other is now invalid. You need to make sure that your compiler optimization settings for volatility are correct, otherwise the compiler could generate code that does not always work correctly.

What is meant by irregular dimensional array?

An irregular dimensional array is a special type of multi-dimensional array.

First we must understand that a multi-dimensional array is just an array of arrays. Each element in the array is, itself, an array of elements.

A regular multi-dimensional array will be an array of size n, with each element containing a separate array of size m. That is, each sub-array has the same size.

An irregular multi-dimensional array will be a multi-dimensional array in which each sub-array does not contain the same number of elements.

Regular array:
array[0] = new array{0, 1, 2}
array[1] = new array{3, 4, 5}
array[2] = new array{6, 7, 8}
array[3] = new array{9, 10, 11}

This regular array is an array of size 4 in which each sub-array is of size 3.


Irregular array:
array[0] = new array{0, 1, 2}
array[1] = new array{3, 4}
array[2] = new array{5, 6, 7}
array[3] = new array{8, 9, 10, 11}

This irregular array is an array of size 4 in which the size of each sub-array is not the same.

What is the modulus used for in programming?

The modulus operator (%) is used to return the partial value that remains when the first operand is divided by the second. If you recall learning long division, most systems start with a "remainder" that is a whole number rather than a decimal point. The modulus returns this value.

For example 10 % 3 means "Take the number ten and find the nearest full division of 3, which in this case would be 9 (3 * 3). Then take that number, and subtract it from the original number, 10."

You see modulus used a lot to determine whether a number is even or odd. This for loop (written in PHP) will produce HTML table rows, with the even rows give the class of "even."

<?php

$rowset = '';

$set = array ( 'a', 'b', 'c', 'd', 'e', 'f', 'g' );

for ( $i = 1; $i <= count ( $set ); $i++ )

{

if ( $i % 2 == 0 0

{

$class = 'class="even"';

}else{

$class = '';

}

$rowset .= '<tr '.$class.'><td>'.$set[$i].'</td></tr>';

}

echo $rowset;

How can you insert a new node in a linked list before any given node within the linked list in O of 1?

you dont. you insert a node after it and copy all contents of the previous node in it and put the new values in the old node. just make sure to keep the connections intact.

Data modeling in system analysis and design?

data modelling is used for organising and structuring of data. we can get overview through generic modelling. organising of data means representing the data in such a way that it comes in a particular order via graphical representation.

Lexmark z645 and the disc is 640 but it does not work on your computer this is a printer?

Unless it states otherwise you can usually use most drivers in the z64x family.

Go to Lexmarks support site and see if they have updated drivers. They also have the manuals there.

You can also go into properties and see if you can renew the drivers.

Go to the Device Manager and see if the printer is showing up or not.

Can you see the printer in the computer and does it send the print job but doesn't make it to the printer? If so then if it's connected to a router via USB then it's probably a network problem, either the login or the connection is the problem. Trade USB cables.

Meaning of variables?

If you are asking, "What is the meaning of the word 'variables' ", then a variable is an amount, one of the facts given, in a question. In the question,

"How fast is a car going that travels 10 km in one hour?" The variables are: * 10 km in distance * 1 hour of time.

How Cadbury world uses ict?

Cocoa beans are shipped off to their destination

The cocoa beans are delivered by truck to the Cadburys factory

They are then put into a large rotating drum to clean and roast.

They then get mashed into a paste called cocoa mass and take out the cocoa butter for safe keeping

Truck drives the cocoa mass to Harrowford.

Turned into crumbs which is then driven to the Bourneville factory

The crumbs get ground into a fine powder by a milling machine.

The cocoa butter is stored in giant tanks and goes down pipes into the conching area which is the mixing of the butter and cocoa powder which then turns into liquid chocolate

Gets strained through vibrating sieves

The mixture then gets tempered which means heating it then cooling it. There is a critical temperature. It takes a long time so it gets the right consistency

Once the chocolate is cooled it is squirted into moulds which are constantly vibrating to shake out the air bubbles and even out the mixture

The chocolate goes through a metal detector to ensure safety

If anything goes wrong a person in the control makes sure it works out again

What advantages might a procedural language have over a declarative language?

The procedural and declarative paradigms are not mutually exclusive. For instance, database query languages such as SQL are both declarative and procedural.

Procedural programming is advantageous whenever the programmer knows precisely what steps should be carried out and in what specific order. We use declarative programming when we know exactly what task we want to perform but are not concerned with how that action is performed. The "how" aspect is decided by the language implementation. Declarative programming is extremely high-level, concentrating on the logic of a computation rather than focusing upon control flow.

Procedural programming isn't as high-level as declarative programming and focuses more upon control flow. However, a language implementation is still free to alter the control flow when the order of execution is immaterial to the result of a computation but would result in more efficient code.