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

What is the difference between handles and pointers?

They exist in different contexts. Handles are like... well handles (or keys, tickets, references etc), to access objects (like files, sockets, resources) you have opened (created, allocated, etc); in the program they can be integers or pointers.

How do you write a looping program to check whether input is a buzz number or not?

Buzz numbers are aircraft identification numbers that were applied to American aircraft following the second world war and through the 1960's.

To determine if an input is a buzz number or not, the input must consist of a two- or three-letter manufacturing code and a 3-digit number, separated by a hyphen. The digits are generally the last three digits of the aircraft serial number.

Validating the manufacturing code is relatively simple given there were only 173 issued. However, validating the three-digit code would be impossible without a complete list of all aircraft that were assigned a buzz number. If such a list exists, storing them in sequential order would allow your program to perform a fast binary search to determine if the input were valid or not. In the absence of such a list, the manufacturing code alone would at least tell you which type of aircraft the buzz number (if valid) would have applied to.

How various data type occupy memory in terms of size?

The amount of memory required to store a particular data type is dependent upon the underlying architecture and the language implementation. In C, we can determine the physical characteristic of a particular implementation by including the <limits.h> header.

The <limits.h> header must define the following symbol:

#define CHAR_BIT 8

The value (8) may vary from implementation to implementation, however the standard dictates that it must be at least 8. Thus a char is always at least 8 bits in length.

For any type T, sizeof(T) returns the length of T in chars. Thus sizeof(char) is guaranteed to be 1 (char) across all implementations while sizeof(T) * CHAR_BIT will determine the number of bits. A char is the smallest unit of addressable storage, thus all type lengths are guaranteed to be at least as long as a char.

The <limits.h> header also provides symbols that we can use to determine the range of values we can store in an integral type (char, long, short, int). For instance, SCHAR_MIN defines the minimum value for a signed char. To determine the range for floating-point types (float, double, long double), include the <float.h> header.

We can also use sizeof() to determine the length of user-defined types, including aliases (typedef), struct and union types. Note that the length of a struct is not necessarily the sum of its member lengths as memory alignment constraints may introduce padding bytes to ensure members are aligned on appropriate word boundaries. For instance, a 32-bit int is faster to access when aligned on a 4-byte boundary.

What type of gas should be used for a 94 camaro with a 34 engine?

Use regular if the engine doesn't ping. Always buy fuel at a place that pumps a lot. If the fuel at the station is always fresh you will have far less problems. Your engine doesn't need fuel with detergents or high octane unless the engine has been significantly modified to raise compression. Even then, it doesn't need expensive fuel, just clean fuel.

Difference between the definition and declaration of a variable in c?

definition defines the memory area ( allocates the memory ) for the variable and the declaration tells about the signature of the variable ( type and size to be considered). definition occures once through the program( memory is allocated once ), but the declaration can occur many times.

OR For a variable, the definition is the statement that actually allocates memory. For example, the statement:

long int var;

is a definition. On the other hand, an extern reference to the same variable:

extern long int var;

is a declaration, since this statement doesn't cause any memory to be allocated. Here's another example of a declaration:

typedef MyType short;

Second Answer

Declaration can come only once and definition can come many times in the program.

Let's take an example,

Line 1: #include

Line 2:

Line 3: void main()

Line 4: {

Line 5: int x; //declaration

Line 6:

Line 7: x=10; //definition

Line 8: }

In the above program, on the line 5 what appears is declaration and on line 7 the definition is there.

Now if we declare the variable x again in the program we will get the error saying that the variable is already declared.

Whereas if we assign some new value to variable x, say 20

i.e.

x=20;

this is totally fine and we can assign any number of values in the same program. This means that the declaration is only one throughout the program but definitions can be many.

How do you convert integer to objects in c?

There are no objects in C, so you can't.

However, in C++ you can convert an integer to an object if the object's class exposes a public conversion constructor that accepts an integer argument. For example:

class X {

public:

X (int); // conversion constructor

// ...

};

How the conversion is implemented depends on the class designer. In the following example, a user can construct a complex number type from an integer:

class complex {

private:

double r;

double i;

public:

complex (double real, double imaginary): r {real}, i {imaginary} {}

complex (int real): r {real}, i {0.0} {}

// ...

};

Here, the implementation implicitly converts the integer to a double and assigns that value to the real representation and assigns the value 0.00 to the imaginary representation. This class may be used as follows:

complex c = 42; // e.g., c.r = 42.0, c.i = 0.0

If a conversion constructor is provided, a corresponding conversion assignment is usually provided as well:

class complex { private:

double r;

double i;

public:

complex (double real, double imaginary): r {real}, i {imaginary} {}

complex (int real): r {real}, i {0.0} {}

complex& operator= (int real) { r = real; i = 0.0; }

// ...

};

This class may be used as follows:

complex c {1.1, -3.14};

// ...

c = 42; // e.g., c.r = 42.0, c.i = 0.0

Compare Contiguous memory allocation with internal fragmentation?

in early, computer system has contiguous memory allocation,each process is allocated in a single contiguous(together) memory!!(allocating into memory addresses one by one,)it has tackled memory fragmentation(both internal and external). not allocating for a fixed size memory block.so no internal fragmentation,

allocating contiguously ,so no external fragmentation!!!

What is meant by the term low-order bits and high-order bits most significant bit?

The bits in a numeric value like

00000000 00110011

have a decimal value based on the bit position. The most significant bit is the one that has highest decimal value and is the left most bit. The right most bit is the least significant bit.

High-order bits are the half of the number of bits that have the highest values, the left most bits in the 16 bit value above The low order bits in this case are the right most bits.

This should not be confused with bit placement in memory/cpu registers. Intel/AMD cpus are little edian, meaning that the most significant part is physically right and the lest significant is left most (the bits are not in reverse order). Google for a more detailed info.

What variables in turbo C?

There are mainly 3 types of variables in c. Integer, Float and character :)

What difference between two nodes in c plus plus of single link list?

Their address. They may also have different values, and their sequence may matter, depending on the design of the algorithm.

What are types of array operation?

Here are some:

Create an array

Destroy it

Access an element of it

What is backslash r carriage return means in c language?

\r means Carriage Return, which means: return the cursor to the beginning of the line in more simple words we can say that it's deleting each character from the active position upto the beginning.

What is the maximum dimension of array can be accepted in c?

C++ doesn't enforce any limits on array dimensions. Limitations are enforced by the hardware. The first limitation is available memory (including virtual memory). The larger the objects in the array, the fewer elements you can create in memory. The second limitation relates to the maximum integer that can be mapped to a size_t data type (which is dependent upon the architecture), however you're far more likely to run out of memory long before reaching this limit.

For instance, a 32-bit system has 4GB of addressable memory, thus (in theory) can accommodate an array of char with a 4,294,967,295 dimension (assuming an 8-bit char type). However, that would leave no memory for the operating system let alone the IDE, so the maximum would be somewhat lower than 4GB.

On a 64-bit system, a 4GB array of char would be perfectly feasible, even if the system only had 2GB of physical memory, due to the much larger address space available (18,446,744,073,709,551,616 bytes).

However, an array that partially requires virtual memory would be tremendously slow to access due to constant swap file access. Depending on the nature of the array, if it requires more memory than is physically available, it might be better handled via a database or as a random access file stream.

How many types of compiler naming in list?

cross compiler .

hybird compiler .

post compiler.

ideal compiler.

intelligence compiler.

How could you extend the range of values four basic data type represent?

use modifier long:

long int, long long, long float

(there is no 'long char' or 'long short' though)

What is the best sorting technique for already sorted array?

If it is already sorted, the best is to leave the array as it is.

If it is already sorted, the best is to leave the array as it is.

If it is already sorted, the best is to leave the array as it is.

If it is already sorted, the best is to leave the array as it is.

How do i Prevent users from saving certain file extensions to c drive using group policy?

Hi Group policy won't do it, but check this: http://blogs.techrepublic.com.com/datacenter/?p=201 File screening on the machine... Habeeb

What are the pseudocode keywords for loop?

Pseudo code does not have key words, you make it up, that's why it is pseudo.