Looking for an everlasting career opportunity on Basic C then visit www.wisdomjobs.com. Basic C with its massive count of applications that includes but not limited to advanced scientific systems, operating systems etc offers individuals with great number of Basic C jobs for freshers as well as experienced on both part time and full time. Look for Basic C jobs interview questions and answers page and understand the interview model to prepare in a strategic way so as to get best results in return. There are plenty of career opportunities for a C certified professional as software developer, C programmer, Analyst, C Specialist etc across many top to small companies in many cities. However your experience levels might be, going through Basic C programming interview Q&As will assist you to perform better during the interview.
Question 1. What Are Volatile Variables?
Answer :
e.g.:
Question 2. Explain The Meaning Of "segmentation Violation"?
Answer :
A segmentation violation usually indicates an attempt to access memory which doesn't even exist.
Segmentation violation usually occurs at the time of a program’s attempt for accessing memory location, which is not allowed to access. The following code should create segmentation violation.
main() {
char *hello = “Hello World”;
*hello = ‘h’;
}
At the time of compiling the program, the string “hello world” is placed in the binary mark of the program which is read-only marked. When loading, the compiler places the string along with other constants in the read-only segment of the memory. While executing a variable *hello is set to point the character ‘h’ , is attempted to write the character ‘h’ into the memory, which cause the segmentation violation. And, compiler does not check for assigning read only locations at compile time.
Question 3. What Is "bus Error"?
Answer :
A bus error indicates an attempt to access memory in an illegal way,perhaps due to an unaligned pointer.
A ‘bus error’ is certain undefined behavior result type. The cause for such error on a system could not be specified by the C language. The memory accessibility which CPU could not address physically, ‘bus error’ occurs. Also, any fault detected by a device by the computer system can also be a ‘bus error’. These errors caused by programs that generate undefined behavior which C language no longer specifies what can happen.
Question 4. Define Recursion In C.?
Answer :
Question 5. What Does Static Variable Mean In C?
Answer :
Static variable is available to a C application, throughout the life time. At the time of starting the program execution, static variables allocations takes place first. In a scenario where one variable is to be used by all the functions (which is accessed by main () function), then the variable need to be declared as static in a C program. The value of the variable is persisted between successive calls to functions. One more significant feature of static variable is that, the address of the variable can be passed to modules and functions which are not in the same C file.
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.
Question 6. List Out Differences Between Structures And Arrays?
Answer :
The following are the differences between structures and arrays:
Question 7. Define Macros. What Are The Advantages And Disadvantages Of Macros?
Answer :
A macro is a name given to a block of C statements as a pre-processor directive. Being a pre-processor, the block of code is communicated to the compiler before entering into the actual coding (main () function). A macro is defined with the preprocessor directive, #define.
The advantage of using macro is the execution speed of the program fragment. When the actual code snippet is to be used, it can be substituted by the name of the macro. The same block of statements, on the other hand, need to be repeatedly hard coded as and when required.
The disadvantage of the macro is the size of the program. The reason is, the pre-processor will replace all the macros in the program by its real definition prior to the compilation process of the program.
Question 8. List Out Differences Between Pass By Reference And Pass By Value?
Answer :
Pass by value always invokes / calls the function or returns a value that is based on the value. This value is passed as a constant or a variable with value.
Pass by reference always invokes / calls the function by passing the address or a pointer to a memory location which contains the value. The memory location / pointer is populated with a value, so the function could look at the value through that location. The function can update the value available in the memory location by referencing the pointer.
A string in C language is passed by reference.
Question 9. Define Static Identifier In C?
Answer :
The static identifier is used for initializing only once, and the value retains during the life time of the program / application. A separate memory is allocated for ‘static’ variables. This value can be used between function calls.
The default value of an uninitialized static variable is zero. A function can also be defined as a static function, which has the same scope of the static variable.
Question 10. What Are The Auto Variables? Where Are They Stored?
Answer :
Question 11. List Out Differences Between Arrays And Linked List?
Answer :
The difference between arrays and linked lists are:
Question 12. Explain The Term Enumerations In C?
Answer :
A set of named integer constants is known as an enumeration. The enumeration type declaration includes the name of the enumeration tag and the definition of a set of named integers.
Ex: enum CITY { Mumbai, Bangalore, Chennai, NewDelhi } metros ;
Variables of enumeration type persists one of the existing values of the enumeration set. The enum type variables could be utilized in indexing expressions, as operands of all arithmetic and relational operators. ANSI C enum expressions are always have int type, which occupies the memory space that occupied by the int type.
Example:
enum DAY /* Defines an enumeration type */
{
saturday, /* Names day and declares a */
sunday = 0, /* variable named workday with */
monday, /* that type */
tuesday,
wednesday, /* wednesday is associated with 3 */
thursday,
friday
} workday;
saturday in the above example is associated with value 0 by default. The identifier sunday is explicitly assigned with 0. The remaining identifiers are given values 1 through 5 by default.
Answer :
The storage allocation / class determine the memory part where the storage space is allocated for variables, functions and how long the allocation of storage continues to exist.
The scope of a variable is specified by its storage allocation. This is specified by the keywords – auto, extern, static and register.
Question 14. What Is The Use Of Typedef?
Answer :
The keyword typedef is used for defining user defined data types. A new definition of existing data types is created by using typedef. It is used to define user defined identifiers which can be used in substitution of type specifiers such as int, float etc. It does not reserve memory space. The names defined by typedef are synonyms for the data types.
For example typedef int integer;
Instead of int the new definition integer can be used for better readability.
Question 15. Can We Specify Variable Field Width In A Scanf() Format String? If Possible How?
Answer :
Example:
scanf("%s", name); // where name is a character array
Question 16. Out Of Fgets() And Gets() Which Function Is Safe To Use And Why?
Answer :
Question 17. List Out Differences Between Strdup() And Strcpy()?
Answer :
The function strcpy() will not allocate the memory space to copy. A pointer to the string to copy and a pointer to place to copy it to should be given.
The function strdup() will occupy / grab itself the memory space for copying the string to. This memory space needs to be freed up later when it is of no use anymore.
Question 18. What Is The Difference Between Char *a And Char A[]?
Answer :
For char[] array, such size is not accepted by the compiler. If the size is specified, the following are the differences between char *a and char a[]:
Question 19. Define Void Pointer?
Answer :
A void pointer is pointer which has no specified data type. The keyword ‘void’ is preceded the pointer variable, because the data type is not specific. It is also known as a generic pointer. The void pointer can be pointed to any type. If needed, the type can be cast.
Ex: float *float_pointer;
int *int_pointer;
void *void_pointer;
. . . . . . . .
. . . . . . . .
void_pointer = float_pointer;
. . . . . . . .
. . . . . . . .
void_pointer = int_pointer;
A void pointer is generally used as function parameters, when the parameter or return type is unknown.
Question 20. What Is A Const Pointer?
Answer :
Question 21. Explain Memory Leak?
Answer :
Question 22. What Is Static Memory Allocation And Dynamic Memory Allocation?
Answer :
Static Memory Allocation: Memory is allocated for the declared variable by the compiler. The address can be obtained by using ‘address of’ operator and can be assigned to a pointer. The memory is allocated during compile time. Since most of the declared variables have static memory, this kind of assigning the address of a variable to a pointer is known as static memory allocation.
Dynamic Memory Allocation: Allocation of memory at the time of execution (run time) is known as dynamic memory allocation. The functions calloc() and malloc() support allocating of dynamic memory. Dynamic allocation of memory space is done by using these functions when value is returned by functions and assigned to pointer variables.
Question 23. What Is The Purpose Of Main( ) Function?
Answer :
The function main() calls / invokes other functions within it. The execution of the program always starts with main() function.
The main() function is :
Question 24. What Is The Difference Between #define And Constant In C?
Answer :
Question 25. What Are Storage Class In C?
Answer :
The scope and lifetime of a variable or / and function within a C program is defined by storage class. There are four storage classes in C
auto - It is the default storage class for all variables and / or functions.
register - Allows for defining variables to store in CPU register instead of RAM. Unary operator is not applied for register variable.
static – The static storage class allows the updated variable values available for the next time when the function, in which the variable is defined , is invoked for the next time.
extern - It allows a global variable to be visible to all the program files / external files ( C programs).
Question 26. Define Register Variables. What Are The Advantages Of Using Register Variables?
Answer :
Advantages of Register variable:
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.