About Me

Hello there! Before talking about qualifications and professional abilities, I would like to introduce myself. I am a Yuvraj Basnet and professional software developer and have been working in this field for 3 long years. I have finished my graduation from The University of Delhi on Computer Science Engineering I considered myself a reasonably experienced programmer with a particular interest in the human side of software development, computers are fascinating machine, but they're mostly reflection of the people using them. In the art of software development, studying code isn't enough; you have to study the people behind the software, too.

Intermediate Level Interview Questions and Answers

Intermediate Level Questions and Answers, c programming interview Q&A, interview Q&A

Intermediate Level Interview Questions and Answers

Hi guys! In the previous article we discussed some important beginner level Q&A now in this article we will discuss some important Intermediate Level Questions and Answers which is asked by the interviewer at the time of interview.
So, let's get started

Question 1. How is a function declared in C language?

Answer- C function declaration is nothing but this informs the compiler about the function name, function parameters and return values of the datatype.

Syntax- return_type func_name(arg list);

  • A function should declared before the calling in C program.
     Example-


















OUTPUT
Enter number for finding square
2
square of the given number 2.000. 4.0000

Question 2. What is Dynamic Memory Allocation? Mention its syntax.

Answer- Dynamic Memory Allocation refers to allocating the memory to the variable at runtime so that the size of variable can be change at run time according to our need.  

Pre defined functions for Dynamic Memory  Allocation:
  • malloc( )- It allocates dynamic memory at the run time. It automatically initializes each block of memory with garbage value.
           Syntax- ptr = (type*) malloc (n*sizeof(datatype));
  • calloc- It allocates dynamic memory at the run time. It automatically  initializes each block of memory with zero value.
          Syntax- ptr = (type*) calloc (n, sizeof(datatype));
  • free( )- It is used to deallocate dynamically allocated memory.
          Syntax- free(ptr);
  • realloc( )- It is used to reallocate dynamic memory which is allocated through calloc() or malloc() function.
          Syntax- ptr = realloc(ptr, newsize);

Question 3. Where can we not use & (address operator) in C?

Answer- Programmers cannot use address operator on constant and variable which can be declared using the register storage class.

Question 4. What is structure in C language?

Answer-
  • Structure is a user define datatype which is constructed by the help of primitive  and derived datatype.
  • It can store more than one value of different types of datatype of different -different memory location.
  • Structure is used with the struct keyword.
  • The size of structure is sum of it's all data member size.
  • The minimum size of structure is 1-byte.
  • Every structure should end with the semi-colon.
      Syntax-  Struct structure_name
                       {
                        body(variable datatype etc);
                       };

Question 4. Differentiate between Call by value and Call by reference?

Answer- 
  • In this case passing value of  variable eg. x(a) whereas In this case passing address of variable eg. x(&a);
  • Can't change value of actual argument using formal argument whereas Can change actual argument using formal argument.
  • No pointer are used whereas pointer are used.
  • It's required more memory whereas It's required less memory.  
  • It is less efficient whereas It is more efficient compare to call by value.
Question 5. Can I create customized header file in C?

Answer- Yes, It is possible to create a new header file. Create a file with function prototypes that need to be used in the program. Include the file in the '# include' section in its name.

Question 6. Differentiate between getch() and getche()?

Answer- getch(): Reads from the keyboard but does not use buffers. So, the data is not displayed on the screen.
getche(): Reads from the keyboard and it uses a buffer. So, data is displayed on the screen.

Question 7. Differentiate between declaring Header file with <> and ""?

Answer- <> the compiler searches for the header file with-in the Built-in path.
"" the compiler will search for the header file in the current working directory. it searches for the file in other locations.

Question 8. What do you mean by  Memory Leak?

Answer- Memory Leak may be defined as a situation where programmer allocates dynamic memory to the program but fail to free or delete the used memory after the completion of the code.

Question 9. Why should we use register storage specifier?

Answer- Programmer can use Register Storage Specifier if certain variable is used very frequently. The variable will be declared in one of the CPU registers.

Question 10. Can I declare same variable in two different scopes?

Answer- Yes, Same variable name can be declared to the variable with different variable scopes.

Question 11. Name different Storage Class Specifiers in C?

  • Answer-  auto
  • register
  • static
  • extern
Question 12. Mention file operations in C language?

Answer- 
  • function - fopen()
          To open a file
  • fclose()
          To close a file
  • fgets()
          To read a file
  • fprint()
          file 

     



    



















Post a Comment

0 Comments