What is a computer casing used for?
It contains all the necessary parts, provides an electrical ground and helps to direct airflow to keep the components cool.
Which is preffered in C malloc or new why?
C does not have a new operator, so we must use the malloc function.
In C++ we prefer the new operator over malloc. The new operator not only allocates memory to an object, it invokes that object's constructor, thus ensuring correct initialisation of the object, thus establishing the object's invariant (if it has one). If construction fails for any reason, an exception will be thrown and no object will be instantiated. If the class designer has made correct use of resource acquisition is initialisation(RAII), any resources consumed by the constructor prior to throwing the exception will be automatically returned to the system, thus ensuring no resource leaks occur.
The sole purpose of malloc is to allocate memory and nothing more. If the allocation fails, a null pointer is returned, otherwise the start address of the allocation is returned. However, the memory is left in an uninitialised state even if the object has a constructor. Moreover, neither malloc, calloc nor realloc will throw exceptions so they are unsuitable for enabling RAII. The only reason they exist at all in C++ is simply for the sake of backward compatibility with C code which cannot use the new operator (since it does not exist in C).
C programming are converted into machine language with the help of?
A software tool called a "compiler" translates C programs into the underlying machine language for the system you are using. The C program is called "source code" and the compiled program is called "object code".
If you compile a program that will run on a completely different type of system, then it's called "cross compiling." Cross compiling requires a special compiler. For example, when you compile an application for the iPhone, you're compiling it on an computer that uses an Intel processor, but the actual program will run on an ARM based processor.
What is the purpose of source management?
Source management is important to ensure that the source of some product is kept safe and up to date. This can refer to many different things, such as the source code of a program, like Google.
What are Dissimilar Fractions?
Dissimilar fractions are fractions whose denominators are not the same. for example 3/8 and 1/2, their denominators are 8 and 2.
Advantage and disadvantage of linked list?
Linked list is a dynamic data structure that contains a "link" to the structure containing the next item. It is a collection of structures ordered not by their physical placement in memory (like array) but by logical links that are stored as part of the data in the structure itself.
Advantages of Linked Lists- Dynamic structure (Mem. Allocated at run-time).
- We can have more than one datatype.
- Re-arrange of linked list is easy (Insertion-Deletion).
- It doesn't waste memory.
Disadvantages of Linked Lists- In linked list, if we want to access any node it is difficult.
- It is occupying more memory.
We can use any method. As we can find out the area of the circle by three methods as i known.
1.ordinary programming
e.g. void main() {
int r;float area;
printf("\n\tEnter radius of the circle : "); scanf("%d",&r); area=3.14*r*r; printf("Radius = %d and area=%f",r,area); } 2. By using macros e.g. #define PI 3.14
#define AREA(x) PI*x*x 3. We can solve by user defined functions also
How do you delete variables that are dynamically allocated?
It depends, especially if you are going to use C++.
If you allocated the variable using the malloc call or any of its derivatives you must use the corresponding 'free' subroutine call to delete them.
If you use the more modern C++ 'new' operator, then use the 'delete' operator to remove the memory dynamically in the program.
#include<stdio.h>
#include<stdlib.h>
typedef struct Node
{
int data;
struct Node *next;
}node;
void insert(node *pointer, int data)
{
/* Iterate through the list till we encounter the last node.*/
while(pointer->next!=NULL)
{
pointer = pointer -> next;
}
/* Allocate memory for the new node and put data in it.*/
pointer->next = (node *)malloc(sizeof(node));
pointer = pointer->next;
pointer->data = data;
pointer->next = NULL;
}
int find(node *pointer, int key)
{
pointer = pointer -> next; //First node is dummy node.
/* Iterate through the entire linked list and search for the key. */
while(pointer!=NULL)
{
if(pointer->data == key) //key is found.
{
return 1;
}
pointer = pointer -> next;//Search in the next node.
}
/*Key is not found */
return 0;
}
void delete(node *pointer, int data)
{
/* Go to the node for which the node next to it has to be deleted */
while(pointer->next!=NULL && (pointer->next)->data != data)
{
pointer = pointer -> next;
}
if(pointer->next==NULL)
{
printf("Element %d is not present in the list\n",data);
return;
}
/* Now pointer points to a node and the node next to it has to be removed */
node *temp;
temp = pointer -> next;
/*temp points to the node which has to be removed*/
pointer->next = temp->next;
/*We removed the node which is next to the pointer (which is also temp) */
free(temp);
/* Beacuse we deleted the node, we no longer require the memory used for it .
free() will deallocate the memory.
*/
return;
}
void print(node *pointer)
{
if(pointer==NULL)
{
return;
}
printf("%d ",pointer->data);
print(pointer->next);
}
int main()
{
/* start always points to the first node of the linked list.
temp is used to point to the last node of the linked list.*/
node *start,*temp;
start = (node *)malloc(sizeof(node));
temp = start;
temp -> next = NULL;
/* Here in this code, we take the first node as a dummy node.
The first node does not contain data, but it used because to avoid handling special cases
in insert and delete functions.
*/
printf("1. Insert\n");
printf("2. Delete\n");
printf("3. Print\n");
printf("4. Find\n");
while(1)
{
int query;
scanf("%d",&query);
if(query==1)
{
int data;
scanf("%d",&data);
insert(start,data);
}
else if(query==2)
{
int data;
scanf("%d",&data);
delete(start,data);
}
else if(query==3)
{
printf("The list is ");
print(start->next);
printf("\n");
}
else if(query==4)
{
int data;
scanf("%d",&data);
int status = find(start,data);
if(status)
{
printf("Element Found\n");
}
else
{
printf("Element Not Found\n");
}
}
}
}
What is the meaning of a knowledge dump?
"Knowledge dump" is a colloquial expression meaning "to transfer a lot of information from one person to another quickly". It could mean a cram course, a briefing session, or any of several other things that carry the same idea.
You may have pressed "Insert" before you typed "prezi". Press "Insert" again to stop this.
What are the implications of using signed vs unsigned bytes in a computer system?
In C programming, the signed and unsignedmodifiers only apply to integer data types: char, short int, int, long int and long long int. Using these modifiers affects the range of values that each of these types can physically represent, however those ranges are implementation-defined.
Although we typically regard a byte as being 8 bits in length, this is not the case at all. In programming, a byte is simply the smallest unit of addressable storage on the system, but the length of a byte is actually determined by the machine architecture of that system.
In C programming, all data types are measured in chars, thus sizeof (char) is always 1 (byte). However, to determine the number of bits per char we need to examine the CHAR_BITS macro defined in
Generally, we don't really need to know the bit-length of an individual char, we simply need to know what range of values the integer types can physically represent (with respect to the current implementation). Again, we look to the macros defined in the implementation's
SCHAR_MIN : Minimum value signed char
SCHAR_MAX : Maximum value signed char
UCHAR_MAX : Maximum value unsigned char
CHAR_MIN : Minimum value char
CHAR_MAX : Maximum value char
SHRT_MIN : Minimum value short int
SHRT_MAX : Maximum value short int
USHRT_MAX : Maximum value unsigned short int
INT_MIN : Minimum value int
INT_MAX : Maximum value int
UINT_MAX : Maximum value unsigned int
LONG_MIN : Minimum value long int
LONG_MAX : Maximum value long int
ULONG_MAX : Maximum value unsigned long int
LLONG_MIN : Minimum value long long int
LLONG_MAX : Maximum value long long int
ULLONG_MAX : Maximum value unsigned long long int
Note that there are no macros defining the minimum value of unsigned data types because the minimum value for any unsigned data type is always 0. Also, a "plain" int is always signed, hence there is no SINT_MIN or SINT_MAX macro.
The char, signed char and unsigned char are three distinct types. The standard does not specify whether a "plain" char should be signed or unsigned, but its range must match that of either the signed char or unsigned char data types. To determine whether a plain char is signed or not, we can use the following:
bool signed_char = ((int) CHAR_MAX == (int) SCHAR_MAX) ? true : false;
If signed_char is true, a char is equivalent to a signed char, otherwise it is equivalent to an unsigned char.
Negative integer values are either represented using ones-complement or twos-complement notation. Again, this is implementation-defined although most modern systems use twos-complement. To determine which notation is in use, we simply look to the minimum value of a signed char. Assuming an 8-bit char, a ones-complement system defines SCHAR_MIN as being -127 while a twos-complement system uses -128.
In ones-complement notation, to flip the sign we simply invert all the bits, thus 01010101 becomes 10101010 (the ones-complement of 01010101). The high-order bit denotes the sign (0 for positive, 1 for negative). However, this then means that we have two distinct representations for the value zero: 00000000 (+0) and 11111111 (-0) but zero is neither positive nor negative. To eliminate this inconsistency, twos-complement adds one to the ones-complement, thus 11111111 + 1 = 00000000 (the overflowing bit is simply ignored). By eliminating the redundant representation for -0, the negative range of values increases by 1.
One of the implications of using signed and unsigned data types is that we must be careful when performing mixed-mode arithmetic as this can result in "narrowing" or loss of information. For instance:
void f (signed char s, unsigned char u) {
u = (unsigned) s; // ouch!
}
Here we used an explicit cast, however if s is negative we will lose information because an unsigned type cannot represent a negative value. Conversely, if s is positive, we don't lose information because the upper range of u exceeds that of s. So before converting between signed and unsigned representations, it is worth ensuring the value is within the range of valid values. When converting from unsigned to signed, it's usually a good idea to use a larger signed data type.
There is a concept called as Virtual memory. Here, The pages which are not present in the RAM are placed in the hard disk. Whenever the CPU tries to access a page which is not in RAM, it results in a "Page Fault". Then, the required page is searched in the hard disk and then a victim page is selected in the RAM which is to be replaced. This is done using algorithms like LRU, FIFO, etc. Now, the victim page in RAM is swapped with the new page which is taken from the hard disk. After that, the CPU resumes the execution.
An interpreter, in computer programming, is software that takes an accepted syntax, and "interprets" it for the processor, which then executes the results of the interpretation. This is different than a compiler, which directly outputs machine code into a separate binary file (C++ falls in this category), and also different from a script, which is typically run without an integrated, interactive debugging environment (Perl falls in this category).
BASIC is a programming language that was designed to be a beginner's programming language, lacking many features that would be found in many "complicated" languages, such as object-oriented programming, template programming, etc. Many other features, such as function calls, were made explicit compared to other similar languages. For example, in most languages, you would simply type the name of a function to execute it, while in BASIC, you would use GOSUB to explicitly call the function.
This is not a question, it is an assignment.
class Geo {
public:
virtual double area (void) const = 0;
virtual ~Geo (void) {}
// ...
};
class Rect : public Geo {
private:
double m_width;
double m_height;
public:
Rect (double width, double height): m_width (width), m_height (height) {}
double area (void) const override { return m_width * m_height; }
~Rect (void) override {};
// ...
};
class Sqr : public Rect {
public:
Sqr (double width): Rect {width, width} {}
~Sqr (void) override {}
// ...
};
What is a final catch statement?
A "final catch" or a "try catch" statement is an exception (error) handling statement that will try to run the code between the final/try and "catch". If an error has been encountered, then the computer will proceed to the catch portion of the statement to prevent the program from terminating on error.
Assembly language to machine language translation is?
Assembly language to machine code translation is a "one to one" translation process, as every individual instruction expressed in the assembly language corresponds to exactly one machine instruction.
Note this does not hold for pseudo instructions or expanding macros, which are supported by some assemblers.
In metric, mega = 1000 kilo = 1000 * 1000 = 1,000,000.
BUT!
In computing everything is relative to bytes (each 8 bits), and thus powers of 2 (due to binary), so:
1 megabyte = 1024 kilobytes = 1024 * 1024 bytes = 1,048,576 bytes.
This is the value of one megabyte, so if we multiply it by 3, we get 3,145,728 bytes.
Explain the process of converting tree to a binary tree?
A general tree is an unordered hierarchical data structure with unlimited children nodes for each parent. A binary tree only has a maximum of two children nodes for each parent, commonly called left node and right node.
Converting from tree to binary tree would simply require that you start with the root node and start copying each node into the binary tree. The only rules would be that each node cannot have more than two children, including the root node.
You alo need to know a little about the target binary tree, such as should it be ordered? Should it be complete?
--
I am just adding few more points to this answer.
In Binary tree each node can have 0,1,2 children. The number children can;t exceed 2, where as in ordinary tree node can have any number of children. So while concerting ordinary tree we should fix the maximum number of nodes.
This is the information i found found from( All the credits goes the original Author, since i forgot original URL, i am pasting contents as it is)
General Trees and Conversion to Binary Trees
General trees are those in which the number of subtrees for any node is not
required to be 0, 1, or 2. The tree may be highly structured and therefore
have 3 subtrees per node in which case it is called a ternary tree.
However, it is often the case that the number of subtrees for any node may
be variable. Some nodes may have 1 or no subtrees, others may have 3, some
4, or any other combination. The ternary tree is just a special case of a
general tree (as is true of the binary tree).
General trees can be represented as ADT's in whatever form they exist.
However, there are some substantial problems. First, the number of references
for each node must be equal to the maximum that will be used in the tree.
Obviously, some real problems are presented when another subtree is added to
a node which already has the maximum number attached to it. It is also
obvious that most of the algorithms for searching, traversing, adding and
deleting nodes become much more complex in that they must now cope with
situations where there are not just two possibilities for any node but
multiple possibilities. It is also possible to represent a general tree in
a graph data structure (to be discussed later) but many of the advantages of
the tree processes are lost.
Fortunately, general trees can be converted to binary trees. They don't
often end up being well formed or full, but the advantages accrue from
being able to use the algorithms for processing that are used for binary
trees with minor modifications. Therefore, each node requires only two
references but these are not designated as left or right. Instead they are
designated as the reference to the first child and the reference to next
sibling. Therefore the usual left pointer really points to the first child
of the node and the usual right pointer points to the next sibling of the
node. One obvious saving in this structure is the number of fields which
must be used for references. In this way, moving right from a node accesses
the siblings of the node ( that is all of those nodes on the same level as
the node in the general tree). Moving left and then right accesses all of
the children of the node (that is the nodes on the next level of the general
tree).
Creating a Binary Tree from a General Tree
Since the references now access either the first child or successive siblings,
the process must use this type of information rather than magnitude as was
the case for the binary search tree. Note that the resulting tree is a
binary tree but not a binary search tree.
The process of converting the general tree to a binary tree is as follows:
* use the root of the general tree as the root of the binary tree
* determine the first child of the root. This is the leftmost node in the
general tree at the next level
* insert this node. The child reference of the parent node refers to this
node
* continue finding the first child of each parent node and insert it below
the parent node with the child reference of the parent to this node.
* when no more first children exist in the path just used, move back to the
parent of the last node entered and repeat the above process. In other
words, determine the first sibling of the last node entered.
* complete the tree for all nodes. In order to locate where the node fits
you must search for the first child at that level and then follow the
sibling references to a nil where the next sibling can be inserted. The
children of any sibling node can be inserted by locating the parent and then
inserting the first child. Then the above process is repeated.
Traversing the Tree
Since the general tree has now been represented as a binary tree the
algorithms which were used for the binary tree can now be used for the
general tree (which is actually a binary tree). In-order traversals make no
sense when a general tree is converted to a binary tree. In the general
tree each node can have more than two children so trying to insert the
parent node in between the children is rather difficult, especially if there
are an odd number of children.
Pre-order
This is a process where the root is accessed and processed and then each of
the subtrees is preorder processed. It is also called a depth-first
traversal. With the proper algorithm which prints the contents of the nodes
in the traversal it is possible to obtain the original general tree. The
algorithm has the following general steps:
* process the root node and move left to the first child.
* each time the reference moves to a new child node, the print should be
indented one tab stop and then the node processed
* when no more first children remain then the processing involves the right
sub-tree of the parent node. This is indicated by the nil reference to
another first child but a usable reference to siblings. Therefore the first
sibling is accessed and processed.
* if this node has any children they must be processed before moving on to
other siblings. Therefore the number of tabs is increased by one and the
siblings processed. If there are no children the processing continues
through the siblings.
* each time a sibling list is exhausted and a new node is accessed the
number of tab stops is decreased by one.
In this way the resulting printout has all nodes at any given level starting
in the same tab column. It is relatively easy to draw lines to produce the
original general tree except that the tree is on its side with it's root at
the left rather than with the root at the top.
What is mean by volatile fluid?
What does Volatile mean:
A volatile liquid evaporates faster because of it's low boiling point.