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
Copyright © 2025. Powered by Intellect Software Ltd