1. Question:What is the difference between ordinary variable and pointer in C? 

    Answer
    An ordinary variable is like a container it can hold any value and we can change the value of ordinary variable at a time throughout the program .A pointer is a variable that stores the address of another Variable.

    1. Report
  2. Question:When should a type cast be used? 

    Answer
    There are two situations in which to use a type cast. The first use is to change the type of an operand to an arithmetic operation so that the operation will be performed properly.
    The second case is to cast pointer types to and from void * in order to interface with functions that expect or return void pointers. For example, the following line type casts the return value of the call to malloc() to be a pointer to a foo structure.
    struct foo *p = (struct foo *) malloc(sizeof(struct foo));

    1. Report
  3. Question:What is the difference between %d and %*d in c language? 

    Answer
    %d give the original value of the variable and %*d give the address of the variable.
    
    eg:-int a=10,b=20;
    printf("%d%d",a,b);
    printf("%*d%*d",a,b);
    
    Result is 10 20 1775 1775 .Here 1775 is the starting address of the memory allocation for the integer.a and b having same address because of contagious memory allocation.

    1. Report
  4. Question:How does a C program come to know about command line arguments? 

    Answer
    When we execute our C program, operating system loads the program into memory. In case of DOS, it first loads 256 bytes into memory, called program segment prefix. This contains file tables,environment segment, and command line information. When we compile the C program the compiler inserts additional code that parses the command, assigning it to the argv array, making the arguments easily accessible within our C program.

    1. Report
  5. Question:How are pointer variables initialized? 

    Answer
    Pointer variable are initialized by one of the following two ways
    - Static memory allocation
    - Dynamic memory allocation

    1. Report
  6. Question:What is modular programming? 

    Answer
    If a program is large, it is subdivided into a number of smaller
    programs that are called modules or subprograms. If a complex
    problem is solved using more modules, this approach is known as
    modular programming

    1. Report
  7. Question:Where does global, static, local, register variables and C Program instructions get stored? 

    Answer
    Global , static, local :  In main memory          
    Register variable: In registers
    C program : In main memory.

    1. Report
  8. Question:What is an argument? Differentiate between formal arguments and actual arguments? 

    Answer
    An argument is an entity used to pass the data from calling function to
    the called function. Formal arguments are the arguments available in
    the function definition. They are preceded by their own data types.
    Actual arguments are available in the function call.

    1. Report
  9. Question:When is a switch statement better than multiple if statements? 

    Answer
    A switch statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type.

    1. Report
  10. Question:Differentiate between a linker and linkage? 

    Answer
    A linker converts an object code into an executable code by linking together the necessary build in functions. The form and place of declaration where the variable is declared in a program determine the
    linkage of variable.

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd