answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

When will compilation error occur?

Syntax errors are typically picked up at design time by the code editor. If the programmer is no using a code editor (he is using notepad, for instance), syntax errors become compile time errors.

Describe the functions of the 8086 queue?

The 8086/8088 instruction queue is a buffer that holds opcode bytes that have been prefetched by the bus interface unit. This speeds up operations of the processor by helping to reduce fetch latency, i.e. to improve the probability that an opcode byte fetched by the processor is already available.

What is the binary number 11110000 in a decimal?

11110000 in decimal
(1 * 128) + (1* 64) + (1 * 32) + (1 * 16) + (0 * 8) + (0 * 4) + (0 * 2) + (0 * 1) =
128 + 64 + 32 + 16 + 0 + 0 + 0 + 0 =
240

What are the steps for a systematic approach to problem solving?

1. sit on chair and relax 2. watch t.v. all day 3. don't do anything 4. eat chips and ice cream all day 5. go to sleep 6. there are so many things you can do that I'm to lazy to say etc. XD

What does percent 3.2f means in c language?

3 digit wide and 2 digit precision. But some compiler wont show wide difference !!

What is execution unit and bus interface unit?

In the 8086/8088, the execution unit is the part of the processor known as the CPU. It executes the instructions and generates the results. The bus interface unit, on the other hand, is the part of the processor that handles reading and writing to memory. The two are somewhat loosely coupled, with the bus interface unit attempting to always be ahead of the execution unit, i.e. using the cache, so that the execution unit's wait time is minimized and performance is maximized.

A pseudocode for finding the area of any circle?

Get radius (as parameter)

Calculate area = pi x radius squared

Return area

The above assumes you write a function or method that calculates the area and returns it.

Otherwise:

Ask for radius

Calculate area = pix radius squared

Show area

What are the disadvantages of unions over structures?

There are no disadvantages as such. This is really no different to choosing between using a float or an integral type. Each is intended for a specific purpose so there's really no point looking for disadvantages of one over the other. It's far better to simply look at the purpose for which each was intended and decide which to use according to your needs.

A structure is an aggregate of two or more members where every member has its own address and may be accessed independently of the other members (changing the value of one member does not affect any other members). The members of a union, however, share the same memory address and thus only one value may be stored in a union at any given moment.

The size of a union is equal to the largest member of that union, plus any padding bytes required to bring the total size up to the nearest word boundary (typically a 4-byte boundary on a 32-bit machine). The size of a structure, however, is equal to the sum of its member sizes plus any padding bytes require to align the individual members as well as the structure itself. In memory-restricted systems, it is best to declare members in order of size, largest first, to conserve memory.

Basically, you use a structure as you would a database record, to group related data elements as a single entity, such as a person's name, their address, telephone number and other contact details when creating a list of contacts.

You use a union when you need to be able to store two or more different types of information but only require access to one specific type at a time. For instance, if a piece of data can either be referred to by name or by number, but never both, a union makes sense as you don't waste memory allocating storage for two separate pieces of data when you only actually require one value in memory at any given moment.

Note that the relationship between the data stored in a union and the member that was used to write that data purely conventional. It is entirely up to the programmer to keep track of which member was last used to write the data and thus read back that data correctly. Although it is an error to write through one member and subsequently read through another, it is not illegal. However, such code should be treated with suspicion:

"Unions are often misused for 'type conversion'. This misuse is practiced mainly by programmers trained in languages that do not have explicit type conversion facilities, so that cheating is necessary. For example, the following "converts" an int to int* simply by assuming bitwise equivalence:

union Fudge {

int i;

int* p;

};

int* cheat (int i) {

Fudge a;

a.i = i;

return a.p; // bad use

}

"This is not really a conversion at all. On some machines, an int and an int* do not occupy the same amount of space, while on others, no integer can have an odd address. Such use of a union is dangerous and non-portable." [Bjarne Stroustrup, The C++ Programming Language, Fourth Edition].

In order to use a union correctly, it is often necessary to use a "type field" to keep track of the active member. Both the type field and the union it relates to are typically declared as members of the same structure, thus making the relationship between the data and its type more concrete. For instance, if a piece of data can be represented by a string or by an integer (a name or a number), we might use the following enum, union and structure:

typedef enum type_field {name, number};

typedef union my_union_t {

char* pstr;

int num;

} my_union;

typedef struct my_struct_t {

type_field type;

my_union data;

} my_struct;

Whenever we need to write to the my_struct.data member, we first change the my_struct.type member to the appropriate type (name or number), and then write to my_struct.data.pstr or my_struct.data.int as appropriate. when we wish to read back the data, we test the my_struct.type member and then read back the appropriate member of my_struct.data.

Note that although it may seem we are using just a much memory as we would with a structure alone, by virtue of the use a type field, we'd still have to use a type field if we used a structure instead of a union because we'd still need to know which member was "active", even if those members did not share a memory address.

Although unions can be essential for compactness of data and performance, most programs don't improve much from the use of unions and unions are somewhat error-prone due to the onus being on the programmer to ensure data is read correctly. In C++, many of the advantages of a union can also be rendered moot by the used of derived classes, however we can also encapsulate a union within a class and thus shift the onus of responsibility to the class itself, thereby ensuring data is always interpreted correctly.

What a java program to find largest and smallest value store in the array?

Implement these methods:

public static int smallest(int[] arr) {

int small = arr[0];

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

if(arr[i] < small)

small = arr[i];

return small;

}

public static int largest(int[] arr) {

int large = arr[0];

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

if(arr[i] > large)

large = arr[i];

return large;

}

What does med arr txble means?

MEDical ARRears TaXaBLE. This information is from Walmart HR. My wife signed up for medical in the middle of a monthly medical period. This one time $50 charge is the difference for the monthly medical period prior to the payment for the pay period.

How do you convert exe to binary?

An exe is machine code and machine code is written entirely in binary. No conversion is necessary.

A hex-editor is the simplest way to view the binary code. The code will be shown in hexadecimal rather than binary, however this actually makes it much easier for humans to interpret the binary code because the conversion from hex to binary is so simple. Each hex digit represents a unique 4-bit binary pattern:

0x0 = 0000

0x1 = 0001

0x2 = 0010

0x3 = 0011

0x4 = 0100

0x5 = 0101

0x6 = 0110

0x7 = 0111

0x8 = 1000

0x9 = 1001

0xA = 1010

0xB = 1011

0xC = 1100

0xD = 1101

0xE= 1110

0xF = 1111

Thus the hex value 0x9A translates directly to the 8-bit binary value 10011010. That is, 8 binary digits reduce to just 2 hex digits and therefore makes it much easier for humans to interpret the binary value.

What data type is weight?

Weight is typically represented by a floating point type (a real number). However, depending on the precision required by the programmer, a weight can also be represented as an unsigned integral (a positive whole number). Note that floating point types are always signed.

What is inline function in C Can you make inline function recursive or not If make can complier will compile that code?

The inline attribute is a C++ attribute, not a C attribute.

Inline specifies that the function is to be expanded in place at the point of call instead of being called as a function. This means there will be one copy of the function for each call. This costs executable code, but can save execution time because the call setup and return time is avoided. Some functions cannot be inlined, and inline is really only a hint to the compiler.

As far as recursive inlined functions, that depends on the implementation. The Microsoft implementation will not inline recursive functions unless they have a #pragma inline depth(n) line that specifies the maximum recusion depth the function will have. Consult your specific compiler documentation for the inline attribute for your specific implementation details.

What is null derivative?

A null derivative occurs when an increasing function does not have a derivative. This is most commonly seen in the question mark function.