Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
seminar class
Active In SP

Posts: 5,361
Joined: Feb 2011
26-02-2011, 11:46 AM

.docx   TECHNICAL_QUESTIONS.docx (Size: 19.89 KB / Downloads: 49)
1. What does static variable mean?
Ans: A static variable is program variable that does not vary.
Static variables have the same value throughout run time. They can be changed at design time only.
static is an access qualifier that limits the scope but causes the variable to exist for the lifetime of the program. This means a static variable is one that is not seen outside the function in which it is declared but which remains until the program terminates. It also means that the value of the variable persists between successive calls to a function. The value of such a variable will remain and may be seen even after calls to a function. One more thing is that a declaration statement of such a variable inside a function will be executed only once.
2. What is a pointer?
A pointer is a variable that contains the memory location of another variable. The syntax is as shown below. You start by specifying the type of data stored in the location identified by the pointer. The asterisk tells the compiler that you are creating a pointer variable. Finally you give the name of thevariable.
type * variable name
int *ptr;
float *string;
The notation for manipulating pointers is not obvious because it uses the asterisk (*) for two different purposes, and in C++ the ampersand (&) is used in an additional way (declaring by-reference function parameters). However, in C there are really only three ways in which you will use the asterisk and ampersand with pointers. You may need to refer back to these three examples for a while, but eventually you will find their use straightforward.
Declaring a pointer
int* example; /* Declares a pointer to an int. */
Getting the address of a variable.
int something = 3;
example = &something. /* Makes example point to the address of something. */
Dereferencing a pointer
*example = 2; /* Sets the value of the data pointed to by example. */
3. What is a structure?
In some programming contexts, you need to access multiple data types under a single name for easy manipulation; for example you want to refer to address with multiple data like house number, street, zip code, country C supports structure which allows you to wrap one or more variables with different data types. A structure can contain any validdata types like int, char, float even arrays and other structures. Each variable in structureis called a structure member.
Defining structure
To define a structure, you can use struct keyword. Here is the common syntax ofstructure definition:
struct struct_name{ structure_member };
The name of structure is followed the rule of variable name. Here is an example of defining address structure:
1.struct address{
2.unsigned int house_number;
3.char street_name[50]; zip_code;
5.char country[50];
It contains house number as an positive integer, street name as a string, zip code as an integer and country as a string.
4. What are the differences between structures and arrays?
Arrays are collections of repeated data items. Structures are complex data items made up of other data items, including, potentially, other structures and arrays. You can, of course, also have arrays of structures.
5. In header files whether functions are declared or defined?
6. What are the differences between malloc() and calloc()?
Malloc()- it is used to allocate only
There are two differences. First, is in the number of arguments. Malloc() takes a single argument (memory required in bytes), while calloc() needs two arguments (number of variables to allocate memory, size in bytes of a single variable). Secondly, malloc() does not initialize the memory allocated, while calloc() initializes the allocated memory to ZERO.
7. What are macros? what are its advantages and disadvantages?
8. Difference between pass by reference and pass by value?
9. What is static identifier?
Static identifier is an identifier whose value remain only in the scope in which it has been defined.
In C, if a local variable is declared static, a separate memory location is allocated for that variable. This variable retains the value between function calls, like a global variable. So next time when a function is called again it finds the old value. Also a local static variable is initialized only once. Eg:
void increment(void) { static int x = 1; x++; printf("%d
",x); } Here every time this function is called, x doesn't get initialized. So output would be 2 3 etc
Also if a global variable is declared static, it can only be accessed in that file. We cannot access it from other files as we can do for general global variable by using extern.
The default initial value of an uninitialized local static variable is zero
10. Where are the auto variables stored?
Auto variables are stored in memory and their default value is a garbage value. Register variables are meant to be stored in processor registers.
for instance if we write register int i; then i should be stored in a register. it may or may get the place in a register depending upon whether there are sufficient registers available or not because in microcomputers there are usually 14 to 16 registers and they may be engaged in some other work.

11. Where does global, static, local, register variables, free memory and C Program instructions get stored?
Local Variables are stored in Stack. Register variables are stored in Register. Global & static variables are stored in data segment. The memory created dynamically are stored in Heap And the C program instructions get stored in code segment and the extern variables also stored in data segment.

Important Note..!

If you are not satisfied with above reply ,..Please


So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page

Quick Reply
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)