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

Device an algorithm for weiler-atherton polygon clipping where the clipping window can be any specified polygon?

Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

What is the difference between post and pre increment unary operators in c with example?

They both increment the variable. But the value returned by the pre-increment operator is the value of the variable after it has been incremented, while the value returned by the post-increment operator is the value before it has been incremented.

For example:

int a = 1;

int b = ++a;

// Now a is 2 and b is also 2.

int a = 1;

int b = a++;

// Now a is 2 but b is 1.

Local variable if not initialized contains what?

It contains data which left after previous usage of that area of the memory.

What is the rationale to using a date format model?

It is a document that seeks reasons behind any decision made for designing a system. It's on most occasionally argumentÊ based.

How does information systems literacy differ from computer literacy?

Information system literacy is networks, or IT. Those in IT are always computer literate.

Not everybody who is computer literate is information system literate.

What is structural language?

C is block structured. It uses brackets to start blocks and end them. They nest. Scope rules allow variables code to be accessed from limited parts of your program.

Let me just say this again. Block structure is not the same as object oriented. C++ is both. It is somewhat compatible with C, retaining it's block structure. It also has syntax to allow you to bind objects to procedures (methods). C is not object oriented.

How do you calculate the average of unknown number of tests?

If the average of 5 numbers is 23 and the range is 10, what are the 5 numbers?

Implement a queue using a singly linked list l the operations insert and delete should still take o1time?

Suppose we have a Queue as follows: E -> D -> C -> B

We maintain a head pointer to E and a tail pointer to B.

To add an element, we make a new queue item (say A), we set B->next = A, and set tail = A.

To delete an element, we let a temp pointer to the head (say tempHead = head), set head = E->next and deallocate tempHead.

What is the ASCII value of -1?

acii value of 1 is 49

for a complete list check out:

http://www.killersites.com/webDesignersHandbook/ascii_page2.htm

What are the advantages and disadvantages of dynamic memory allocation and the allocation of files in secondary storage?

Two disadvantages of dynamic allocation: a) Freeing memory b) Fragmentation
Freeing MemoryThe user is responsible for freeing up memory when he is finished with it. This is a serious responsibility, a potential source of bugs that are very hard to find.

For example, suppose you free up a location before you're actually finished with it. Then further access to the location will either cause a run-time error (memory violation) or, what is worse (but more common), you will get access to a location that is being used for some completely unrelated purpose.

Trouble also occurs if you forget to free up some space. If you do this, you are losing the advantages of dynamic allocation. And in some circumstances - e.g. if you were writing the program that manages the space on a disk drive - this could be disastrous.

There are no surefire safeguards against these problems, you must be very careful when writing programs to return memory when you are finished with it, but not before.

Fragmentation of MemoryAs the preceding example demonstrated, with dynamic allocation the `free' parts of memory are not all together in one contiguous block. When we returned JOE's memory, we had 4 free cells on one side of MARYJANE and all the rest on the other side. This is called fragmentation of memory, and it can grow into a very serious problem: it is possible to have a large amount of free memory but for it to be broken up into such tiny fragments that there is not enough contiguous free space to store another name.

Suppose that after using dynamic allocation for a while memory becomes fragmented thus:

and that we need to obtain a block this big: If only the remaining free blocks were contiguous, we'd have enough room, but, in the present configuration, it looks like we are doomed. There are several possible solutions to this problem. The one we will study is based on the insight that a large data structure does not necessarily have to be allocated in one single contiguous chunk of memory. Instead it might be decomposed into smaller components that are somehow linked together in a chain.

Does Ubuntu support Microsoft Visual C?

Out of the box, Ubuntu does not support ANY Windows programs, released by Microsoft or not. If you install Wine on Ubuntu, With Wine installed, you can run Visual Studio .NET 2003, but no later version.

How do you write platform independent C code?

Platform-Independent code, is a code that can run on any Operating System. So to write Platform-Independent codes, don't use codes that can work ONLY in the OS you program it in. w4r3_w01f at live dot com

Can memory which has been allocated by new be freed by free?

No, you have to use the operator delete to objects created by new.

The basic functions of many programs are?

input data, processing, output data

reference:Microsoft Visual Basic 2012 Introductory

Can i transfer from computer monitor to TV?

The video card in your computer must have a tv out ,composite or s video. standard tv's are 480x640 so it is not good quality

What does the linker error message type is absolute and non-overlay but occurs in more than one input file mean?

The linker error message type is absolute and non-overlay but occurs in more than one input file means entry section was included many times. Even entering two times gives the error message.

What is shallow copy in Java?

A shallow copy in Java refers to the copying of object references from one collection to another.

In contrast, a deep copy in Java refers to the copying of actual object data from one collection to another.

// shallow copy

Object[] original = {new Object(), new Object(), new Object()};

Object[] copy = new Object[original.length];

for(int i = 0; i < original.length; ++i)

copy[i] = original[i];

// deep copy

Object[] original = {new Object(), new Object(), new Object()};

Object[] copy = new Object[original.length];

for(int i = 0; i < original.length; ++i)

// this would not compile in this case because Object does not have a publicly

// accessible clone() method. if you were to use this, make sure that the type

// has an accessible clone() method

copy[i] = original[i].clone();

Difference between struct and union?

A union is a way of providing an alternate way of describing the same memory area. In this way, you could have a struct that contains a union, so that the "static", or similar portion of the data is described first, and the portion that changes is described by the union. The idea of a union could be handled in a different way by having 2 different structs defined, and making a pointer to each kind of struct. The pointer to struct "a" could be assigned to the value of a buffer, and the pointer to struct "b" could be assigned to the same buffer, but now a->somefield and b->someotherfield are both located in the same buffer. That is the idea behind a union. It gives different ways to break down the same buffer area.

The difference between structure and union in c are: 1. union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members. 2. In union, one block is used by all the member of the union but in case of structure, each member have their own memory space

Difference in their Usage:While structure enables us treat a number of different variables stored at different in memory , a union enables us to treat the same space in memory as a number of different variables. That is a Union offers a way for a section of memory to be treated as a variable of one type on one occasion and as a different variable of a different type on another occasion.

There is frequent rwquirement while interacting with hardware to access access a byte or group of bytes simultaneously and sometimes each byte individually. Usually union is the answer.

=======Difference With example***** Lets say a structure containing an int,char and float is created and a union containing int char float are declared. struct TT{ int a; float b; char c; } Union UU{ int a; float b; char c; }

sizeof TT(struct) would be >9 bytes (compiler dependent-if int,float, char are taken as 4,4,1)

sizeof UU(Union) would be 4 bytes as supposed from above.If a variable in double exists in union then the size of union and struct would be 8 bytes and cumulative size of all variables in struct.

Detailed Example:struct foo

{

char c;

long l;

char *p;

};

union bar

{

char c;

long l;

char *p;

};

A struct foo contains all of the elements c, l, and p. Each element is

separate and distinct.

A union bar contains only one of the elements c, l, and p at any given

time. Each element is stored in the same memory location (well, they all

start at the same memory location), and you can only refer to the element

which was last stored. (ie: after "barptr->c = 2;" you cannot reference

any of the other elements, such as "barptr->p" without invoking undefined

behavior.)

Try the following program. (Yes, I know it invokes the above-mentioned

"undefined behavior", but most likely will give some sort of output on

most computers.)

======= Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members. In union,one block is used by all the member of the union but in case of structure, each member have their own memory space.

Union allocates the memory equal to the maximum memory requried by the member of the union but structure allocates the memory equal to sum of the memory allocated to its each individual members.

In Union, one block is used by all the member of union but in case of structure, each member have their own memory space.

Union allocates the memory equal to the maximum memory requried by the member of the union but structure allocates the memory equal to total memory requried by the members. In Union, one block is used by all the member of union but in case of structure, each member have their own memory space.