1. What are different types of storage classes in c?
A. There are 4 storage classes in c ie
i)Automatic
ii)Register
iii)Static &
iv)External
i) Automatic(Auto):
Storage: Memory
Default Initial Value: Garbage Value
Scope: Local to block in which variable is declared.
Life: Till the control remain with in block in which variable is declared
ii) Register:
Storage: CPU Registers
Default Initial Value: Garbage Value
Scope: Local to block in which variable is defined.
Life: Till the control remain with in block in which variable is defined.
iii) Static:
Storage: Memory
Default Initial Value: Zero
Scope: Local to block in which variable is defined.
Life: Till value of the variable persists between different function call
iv) External:
Storage: Memory
Default Initial Value: Zero
Scope: Global
Life: As long as program's execution doesn't come to an end.
..................................................................................................................................................
2. What is meant by pointer?
A. It is an Operator(*). It is called Value at address.
A. There are 4 storage classes in c ie
i)Automatic
ii)Register
iii)Static &
iv)External
i) Automatic(Auto):
Storage: Memory
Default Initial Value: Garbage Value
Scope: Local to block in which variable is declared.
Life: Till the control remain with in block in which variable is declared
ii) Register:
Storage: CPU Registers
Default Initial Value: Garbage Value
Scope: Local to block in which variable is defined.
Life: Till the control remain with in block in which variable is defined.
iii) Static:
Storage: Memory
Default Initial Value: Zero
Scope: Local to block in which variable is defined.
Life: Till value of the variable persists between different function call
iv) External:
Storage: Memory
Default Initial Value: Zero
Scope: Global
Life: As long as program's execution doesn't come to an end.
..................................................................................................................................................
2. What is meant by pointer?
A. It is an Operator(*). It is called Value at address.
- Can be applied to any data type
- Declaration
int *j;
int i=10;
j=&i;
...............................................................................................................................................
3. What is meant by "float *s"?
A. It stores the address of floating point variable but not the floating point value.
...................................................................................................................................................
4. How to declare 'pointer to array'?
A. Int (*p)[2]
Brackets to p are necessary
....................................................................................................................................................
5. How to declare 'array to pointer'?
A. Int *s[4]
....................................................................................................................................................
6. How to declare 'pointer to function'?
A. Every function in C is associated with some address
Declaration: int display();
int (*fun-ptr)(); (parenthesis are necessary)
display=fun-ptr; (address assignment)
(*fun-ptr)(); (invokes the function display)
....................................................................................................................................................
7. What is meant by Structure and how to declare it?
A. It is defined as that the data type in which it stores Dissimilar datatypes.
Declaration:
struct book (new data type)
{
char name;
float price;
int pages;
};
....................................................................................................................................................
8. Is it possible to declare any number of variables in structure?
A. Yes, it is possible to declare any number of variables
eg: struct book b1,b2,b3
....................................................................................................................................................
9. What are features of Structure?
A. * The value of structure variable can be assigned to another structure of same type using assignment operator
* One structure can be nested with in another structure.
* A structure variable can also be passed as an argument to function.
* Pointer to applicable to structure
* Main use of structure is database management.
.....................................................................................................................................................
10.What are the uses of structure?
9. What are features of Structure?
A. * The value of structure variable can be assigned to another structure of same type using assignment operator
* One structure can be nested with in another structure.
* A structure variable can also be passed as an argument to function.
* Pointer to applicable to structure
* Main use of structure is database management.
.....................................................................................................................................................
10.What are the uses of structure?
A. * Changing the size of cursor
* Clearing the content of screen
* Placing the cursor to an appropriate position on screen
* Drawing any graphics shape on the screen
* Receiving a key from keyboard
* Checking the memory size of this computer
* Finding out the list of equipment attached to the computer
* Formatting a floppy
* Hiding a file from directory
* Displaying directory of disk
* sending the output to printer
* Interacting with the mouse.
……………………………………………………………………………………………………………
11.What is difference between structures and array?
11.What is difference between structures and array?
A *Array is collection of similar elements
*Structure is a data type which stores dissimilar data types.
* Array is a derived data type
* Structure is user defined data type.
……………………………………………………………………………………………………………
12.What is meant by Malloc() ?
A * It is standard library function
*It is used to allocate memory dynamically during the time of execution.
* By using array we get fixed with some size but using malloc() we can create our own required size by passing number of bytes
* Malloc takes single argument
………………………………………………………………………………………………………………
13.What is Macros?
A Macros are defined labels which can be replaced at any time by the user.
Ex. #define MAX 35
#define Z Printf (Z is used in place of printf)
……………………………………………………………………………………………………………...
14.What is meant by call by value?
A Call by value is defined as “sending the values of the variable as argument”.
Ex. Swap(x,y); ………….> Function calling
Swap(int a,int b) ……………> Function definition
{ …………………}
…………………………………………………………………………………………………………………
15.What is meant by call by Reference?
A Call by Reference is defined as “Passing the address of the variable as argument”.
Ex. Swap(&a,&b); ………….> Function calling
Swap(int *x,int *y) ……………> Function definition
{……………}
………………………………………………………………………………………………………………
0 comments:
Post a Comment