Memory Organization for a process
--------------------------------------------
CODE SEGMENT: contains executable code
DATASEGMENT:contains static and global variable
HEAP SEGMENT:Dynamically allocated variables will be in heap
STACK SEGMENT:For local or automatic variables
PREM G
premgnath@gmail.com
What is difference between memcpy and memmove?
Its similar to typing without insert key ON and OFF
str1="strings are good");
memmove(str1+8,str1+11,4);
returns------ strings are are good
memcpy(str+8,str1+11,4)
returns------ strings are read
memcpy - just copies from source to destination.
memmove - copies from source to destination if buffers overlap, every character is read before another character is written to the same location
memcpy() copies the bytes of data between memory blocks. If the block of memory overlaps, the function might not work properly. Use memmove() to deal with overlapping memory blocks.
memmove() is very much like memcpy() but very flexible as it handles overlapping of memory blocks.
What relationship does a stack and recursion have?
Local variables and formal parameters are stored on the stack. Recursion is the process of calling a function from within itself, saving local variables and formal parameters. Since the stack is a recursive last-in-first-out data structure, the best place to place variables for each step is on the stack.
The classic example is N Factorial...
int nfact (int n) if (n == 2) return n else return nfact (n - 1);
This example only has one formal parameter. If you called it as nfact(10), by the time n reached 2 there would be 9 return addresses and 9 formal parameters on the stack, and nfact() would have been called 9 times. At that point, the stack unwinds due to the return n statement, and the final result is 3628800.
A simplified picture of the stack at n==2 would look like ...
10
return address of caller
9
return address in nfact
8
return address in nfact
7
return address in nfact
6
return address in nfact
5
return address in nfact
4
return address in nfact
3
return address in nfact
2
return address in nfact
More complex code could easily create and manipulate local variables, so long as they were on the stack. Each recursive instance, then, would be properly isolated from its parent and child, and they would not interfere with each other.
Is The controlling expression for a switch statement can be a char?
char is actually integer, even so they are represented with letters. Anyway, yes you can use the controlling expression of type char in switch statements.
Want context free grammar for c language compiler?
we use context free grammer in compiler consctrtion to cheack the validati of input in parsing.
Why the 0 and 1 are binary numbers?
The term binary means based on two numbers only. It would be possible to use any two numbers for a binary system, however, since 0 and 1 are the first two numerals, it was considered reasonable to use those. It could just as easily have been 1 and 2. The advantage of a binary system is that it is easily converted to an electrical circuit state; one number means on, the other number means off. That makes it useful for computers, which are based on electrical circuits.
What is Efficiency of Binary Search tree operations?
If it is an unbalanced binary tree, O( ln( n ) / ln( 2 ) ) is best-case. Worst case is O( n ).
If it is balanced, worst case is O( ln( n ) / ln( 2 ) ).
How do you implement c program for conditional compilation?
Conditional compilation is achieve through preprocessor directives. First, define the preprocessor symbols upon which conditional compilation depends, then test them using #if and #else preprocessor directives. A #endif directive indicates the end of the nearest enclosing conditional block, thus conditional blocks may be nested.
The following example demonstrates how we can conditionally define debug or production code based upon the absence or existence of the NDEBUG symbol:
#ifdef NDEBUG
/* all C code within this block is compiled when NDEBUG is defined (production code) */
#else
/* all C code within this block is compiled when NDEBUG is not defined (debug code) */
#endif
Note that the NDEBUG symbol is typically defined via the command line, however symbols can also be defined or undefined via the source using the #define and #undefine directives. For instance, header files typically require guards to protect against being included more than once in a compilation and preprocessor directives provide the conventional means of ensuring that is the case:
// myheader.h
#ifndef _MYHEADER_H_
#define _MYHEADER_H_
// all header code goes here...
#endif
By convention, preprocessing symbols (macros) are defined with all uppercase and are intentionally ugly to avoid any confusion with C identifiers. Header guards must be unique to each header thus they are typically based upon the header file name itself.
C-source program doesn't rum, you have to compile and link it. The executable rums like any other binary program.
Where is a data statement usually placed in a basic program?
Anywhere really. A data statement (or REM statement) - can be placed anywhere within the program, because the operating system ignores all REM statements.
Write c program to find odd or even no?
For any number n you could use
* (n % 2 == 0), which would be true for an even number, false for odd For an integer i, a simpler method would be
* (i & 1), which would be true for an odd number, false for even
Is it possible to access databases through C-CPP and if so how?
Most database vendors offer an API for this purpose. The usage will vary by vendor, but generally you open a connection, query (or runcommand), check or step through results, close connection. In the MS Windows environment, you can also use ODBC (Open Database Connectivity), which is an API that abstracts (no, its not C++ classes) the database, its tables, and its query language. You still have to install a vendor specific ODBC driver, and a vendor specific database client, so you still need to consult the vendor documentation. The procedure is similar to the non ODBC solution - you open the connection, query it, step through the results cursor, and close the connection.
Tengo una ford ranger de 1991, me esta dando un problema que no se estandarisa, o se que tiene altas y bajas revoluciones que puedo hacer </ P>
int max(int arr[], int arrSize)
{
int maximum = arr[0];
for (int i = 0; i < arrSize; i++)
{
if (maximum < arr[i])
{
maximum = arr;
}
}
return maximum;
}
Please be patient with us mere humans. The answer can only be given when a human has the time to read your question, have the knowledge of C/Java/Windows to be able to write the code that should solve the problem, then the human needs the concentration to sqash all the bugs that will stop the code solveing the question, and then there is the minor issue of getting enough sleep between reading the question and being able to post the solution
Note: This is not a question on the first place, so it should be simply deleted.
What is the least common multiple of decimals and fractions in C?
To calculate the least common multiple (lcm) of decimals (integers) and fractions you first need to calculate the greatest common divisor (gcd) of two integers:
int gcd (int a, int b) {
int c;
while (a != 0) {
c = a;
a = b % a;
b = c;
}
return b;
}
With this function in place, we can calculate the lcm of two integers:
int lcm (int a, int b) {
return a / gcd (a, b) * b;
}
And with this function in place we can calculate the lcm of two fractions (a/b and c/d):
int lcm_fraction (int a, int b, int c, int d) {
return lcm (a, c) / gcd (b, d);
}
What does int mean in clinical setting?
It stands for intermittent needle therapy. It is a peripheral intravenous access site used to administer medications. It remains in the hospitalized client during their entire stay, in case emergency access is needed.
When is it better to pass an entire array of data to a function rather than individual elements?
It is better to do this when the function needs to work on the entire array, rather than on individual elements. However, do not pass the array by value; always pass by reference.
What is the bitwise OR of 35 with 7 in C?
35 OR 7 is 39.
To see how this works, write the values in binary, one directly above the other:
00100011 (35)
00000111 (7)
Each column provides the two input operands for the OR operator. The output is derived from the following truth table:
0 or 0 = 0
0 or 1 = 1
1 or 0 = 1
1 or 1 = 1
Thus when the column has two 0s, we output a 0, otherwise we output a 1. Repeating this for all columns we find the following output:
00100111
Converting this to decimal we can see that 35 OR 7 must be 39.
1 What are the main advantages from using high-level language constructs?
Easy to test program
Easier to implement programming solution
Reduce the repeating code
Easy to change and modify program
Increase the productivity
What are the differences of turbo c plus plus and mother program?
No idea what mother program is, but I assume you mean how does Turbo C++ compare to the ISO C++ standard. The last version of Turbo C++ came out in 2006 and was compliant with the standard at that time. However, Embarcadero (the current owners) no longer support Turbo C++, thus it no longer complies with the current ISO standard.