What is the role of data structure in compiler design?
The role of the data structure in compiler designer is to take an input of a program written in another language and produce an output in another language. It also performs error detection.
Use the Multiple Main method C?
There are no methods in C, and you should have only one main function.
Methods are associated with a specific class, and there are no classes in c.
What is a valid heading for the main program?
For a 'C' program, the main routine must be on of these:
int main (void)
int main (int argc, char ** argv)
int main (int argc, char ** argv, char **envp) /* on some platforms */
Why do you have type data gram socket?
A datagram socket represents a connectionless, non-guaranteed communication protocol. It represents the UDP protocol in the TCP/IP suite.
Contrast this with a stream socket, which represents a connection oriented, guaranteed, communication protocol. It represents the TCP protocol in the TCP/IP suite.
UDP is the underlying protocol for TCP. If you are talking OSI model, UDP is layer 3, and TCP is layer 4.
The simplest solution is to use a std::set<size_t> sequence container to store the values as they are input. Duplicate entries are ignored automatically, thus when all 5 numbers have been input, the set will have at least 1 number but no more than 5. Thus the size of the set represents the count of distinct values that were input.
What is the sie of an array whos upper bound is 100?
To calculate the size of array the type of array should be given.
Ex: if it is of integer type that means int arr[100] and integer is of 4 bytes, then the size of array will be 400 bytes.
The int data type requires more memory than the double data type?
No, the int variable uses less memory, and therefore it is preferable to use an int rather than a double where you can.
A boolean variable uses even less memory, but obviously is useful only in limited circumstances.
Fortran is a low level language?
FORTRAN is a third generation language.
Note: I don't know what these generations are, but I'm quite sure that Fortran is one of the oldest high-level programming languages, as are Cobol and Algol.
Explain the Difference between bitwise operator ' and ' and address operator ' and ' of pointer?
The bitwise logical operator and (&) calculates the bitwise logical and of two integral values. It is a binary operator.
The address of (&) operator returns the address of the value to its right. It is a unary operator.
The distinction between the two is one of context. The logical and operator will follow (and be preceeded by) a value, while the address of operator will follow an operator.
How do you convert a binary number to its hex?
Counting from the right, group the binary into groups of 4. If you are left with less than 4 binary digits, then add preceding zeros.
Then recode each quartet as follows:
0000 = 0 0001 = 1 0010 = 2 0011 = 3
0100 = 4 0101 = 5 0110 = 6 0111 = 7
1000 = 8 1001 = 9 1010 = A 1011 = B
1100 = C 1101 = D 1110 = E 1111 = F
Write various ways to implement stack data structure?
2. Write a program using switch statement that reads a character representing a geometrical figure, then asks the user to enter the required data (ex. Radius for a circle, length and height for a rectangle, etc. ...) . The program should then print the area and circumference.
Figures are: circle(c), square(s), rectangle(r), triangle (t).
Write a c program on blood bank automation system?
Not possible to write one here (too complex). Look for a commercial program to do this.
The simplest way is to add a loop around the ask-for-the-number, show-the-table routine. In pseudocode:
while (1) { ask-for-the-number; show-the-table; }
garbage collection
If necessary, pad the value with zeroes so the number of bits is an exact multiple of 3. Then divide the binary value into groups of 3 bits. Convert each group to its corresponding octal digit as follows:
Bin = Oct
000 = 0
001 = 1
010 = 2
011 = 3
100 = 4
101 = 5
110 = 6
111 = 7
Example 1:
16-bit value: 1011101101100011
3-bit groupings: (00)1 011 101 101 100 011
Octal digits: 1 3 5 4 3
Octal value: 13543
Example 2:
24-bit value: 010111011010010101011010
3-bit groupings: 010 111 011 010 010 101 011 010
Octal digits: 2 7 3 2 2 5 3 2
Octal value: 27322532
If a decimal number has 25 digits then how many bits are required for binary representation?
If this is a homework assignment, please consider trying to answer it yourself first, otherwise the value of the reinforcement of the lesson offered by the assignment will be lost on you.
The largest decimal number with 25 digits is 9,999,999,999,999,999,999,999,999.
The smallest decimal number in the form 2n-1 which is greater than or equal to that is 19,342,813,113,834,066,795,298,815. That corresponds to 284-1.
So, the minimum number of binary bits required to represent the decimal number 25 nines in a row is 84. This is 84 ones in a row. If you want to support negative as well as positive numbers, you will need 85.
Since the largest integer in most compilers is 64 bits, this will require a special library supporting 128 bits, or an arbitrary length decimal library, if you want to manipulate such large numbers in a computer and still retain the precision of an integer.
How can run Terminate and Stay Resident program in windows platform using turboc plus plus?
Terminate and Stay Resident (TSR) programs are a DOS concept, not a Windows concept.
Write and explain recursive backtracking algorithm for n-queens?
This is not a question, this is your homework.
For a start, read this: https://en.wikipedia.org/wiki/Eight_queens_puzzle
How a Round Robin scheduling algorithm allocates the CPU to processes?
The round-robin scheduling algorithm allocates CPU time to processes by sequentially assigning the CPU to processes of equal priority that are in the state of being able to use the CPU. (Not blocked) This works by appearing to evenly distribute the CPU amongst CPU ready processes. Processes that are waiting on something, such as an I/O event, particularly waiting on the user to press Enter, are not considered for allocation. Often, there is a priority assigned to the process, which factors in the allocation strategy. Processes that are mostly I/O intensive tend to have higher priority, giving them good response time. Processes that are mostly CPU intensive tend to have lower priority, so they don't interfere with overall system responsiveness.
Do you have source code in c for assignment operator?
I'm not sure what you mean, but the c assignment operator is the equal sign, =
Define a multiple stack. write algorithm for its implementation?
A multiple stack program is a program with more than one stack. We are talking about program defined stacks, not the implicit stack that runs behind the scenes. One algorithm would be to create a linked list. The push operation, given the address of the pointer to the head of the stack, would allocate and insert an element in front of the head. Pop would retrieve the head and deallocate it. An incomplete example, using integers as the elements... (For readability, ... indicates tabs.) typedef struct stack_element_s {
... struct stack_element_s *next;
... int element;
} stack_element; int push (stack_element **stack_head, int *value) {
... stack_element *temp;
... stack_element *new_element;
... new_element = malloc (sizeof (stack_element));
... if (new_element == null) return 0; /* allocation failure !!! -- FATAL */
... temp = *stack_head;
... new_element->next = temp;
... new_element->element = *value;
... **stack_head = new_element;
... return 1;
} int pop (stack_element **stack_head, int *value) {
... stack_element *temp;
... temp = *stack_head;
... if (temp == null) return 0; /* stack empty */
... *value = temp->element;
... **stack_head = temp->next;
... free temp;
... return 1;
} stack_element *stack1 = null;
stack_element *stack2 = null; /* showing stack1, stack2 is similar. you can have as many stacks as you want */
int value;
if (!push (&stack1, &value)) exception_handler(); /* exception handler */
if (!pop (&stack1, &value)) stack_empty(); /* stack empty */
Uses of automata and compiler design?
Automata is the science of state machines. State machines are (programming) entities with defined states and procedures (rules) for going from one state to another. An example might be an elevator. You define the various states, i.e. open, closed, which floor, which direction, what call buttons are pressed, etc. Then you define the rules, such as not changing directions when there is a call in the same direction. You would not define a rule for going from the first to the third floor, but you would define a rule for going from one floor to an adjacent floor. State machines are well suited to compiler design. If, for instance, you are parsing an expression, you would expect a binary operator to be surrounded by two operands. If you were parsing a while loop, you would expect the while keyword to be followed by an expression in parenthesis, followed by a statement. In automata, you design the basic machine, and provide the rules for going from one state to another. For a compiler, this makes it (relatively) easy to make changes to language syntax because you need only deal with rules, rather than thinking about wide scope procedural changes.