Skip to main content

Posts

C Programming Interview Questions With Answers - Part VII.

43. What Is Static Memory & Dynamic Memory Allocation? Answer: Compiler allocates memory space for a declared variable. By using the address of operator, the reserved address is obtained and this address is assigned to a pointer variable. This way of assigning pointer value to a pointer variable at compilation time is known as static memory allocation. A dynamic memory allocation uses functions such as malloc() or calloc() to get memory dynamically. If these functions are used to get memory dynamically and the values returned by these function are assigned to pointer variables, such a way of allocating memory at run time is known as dynamic memory allocation. 44. What Is Dynamic Memory Allocation? Explain The Various Memory Allocation Function With Its Task. Answer: The mechanism of allocating required amount of memory at run time is called dynamic allocation of memory. Sometimes it is required to allocate memory at runtime. When we declare array in any program, the co...

C Programming Interview Questions With Answers - Part VI.

37. Which Bitwise Operator Is Used For Checking Whether A Particular Bit Is ON Or OFF? Answer: The bitwise AND operator is used for checking whether a particular bit is ON or OFF. 38. Which Bitwise Operator Is Used For Turning OFF A Particular Bit In A Number? Answer: Bitwise AND operator (&) and one’s complement operator (~) are suitable for turning OFF a particular bit in a number. 39. What Are The Bitwise Logical Operators? Answer: Operators that are used for manipulation of data at bit level are known as bitwise operator. Bitwise logical operator are binary operator and require two integer type operand. These work on their operand bit by bit starting from the least significant bit. There are following three logical bitwise operators: Bitwise AND(&) Bitwise OR(|) Bitwise exclusive OR(^) 40. What Is Equivalent Of Multiplying An Unsigned Int By 2: Left Shift Of Number By 1 Or Right Shift Of Number By1? Answer: Left shifting of an unsigned integer...

C Programming Interview Questions With Answers - Part V.

31. Distinguish Between Automatic & Static Variables? Answer: Differences between automatic & static variables are: Automatic variables are declared inside a function in which they are to be utilized, that’s why referred as local or internal variables whereas Static variables may be declared internally or externally. A variable declared inside a function without storage class specification by default is an automatic variable. However, we may use the keyword auto to declare it explicitly. main() { auto int age; } whereas keyword static is used to declare a static variable. Static int age; Default initial value for an automatic variable is Garbage value whereas static variables have zero as default initial value. Automatic variables are created when the function is called and destroyed on exit from the function whereas in case of internal static variable, the scope is local to the function in which defined while scope of external static variable is to all...

C Programming Interview Questions With Answers - Part IV.

22. How Many Types Of Logical Operators Are There In 'C' Programming Language? Answer: C allows usage of three logical operators: For example: (4 == 4) && (5!= 1) evaluates to True (1), because both operands are true. (4 > 1) || (9 < 1) evaluates to True (1), because one operand is true (4 > 1). !(5 == 4) evaluates to True (1), because the operand is false. 23. What Is A Constant Variable? Answer: By default the value of any variable in C is not constant. Hence, to assign a variable with a constant value throughout the program, the variable can be made a constant variable. Constant variable are declared using the const keyword and they make execution faster than non-constant variables. 24. Define Static Variable? Answer: A static variable is a variable which has been allocated statically. i.e., the life of the variable extends as long as the entire run of the program. Static variables are global variables and find wide use in programs. It...

C Programming Interview Questions With Answers - Part III.

15. What Is An Unsigned Integer Constant? What Is The Significance Of Declaring A Constant As Unsigned? Answer: An integer constant is any number in the range -32768 to +32767, because an integer constant always occupies two bytes in memory and in two bytes we cannot store a number bigger than +32767 or smaller than -32768. Out of the two bytes to store an integer, the highest bit is used to store the sign of the integer. This bit is 1 if the number is negative and 0 if number is positive. Unsigned integer constant is an integer constant which has the permissible range from 0 to 65536. Significance of declaring a constant as unsigned almost doubles the size of the largest possible value. This happens because on declaring a constant as unsigned, the sixteenth bit is free and is not used to store the sign of the constant. 16. Differentiate Between Break & Continue Statement? Answer: Two keywords that are very important to looping are break and continue. The break comm...

C Programming Interview Questions With Answers - Part II.

8. State The Differences Between Program Testing & Debugging. Answer: Program Testing is the process of checking program, to verify that it satisfies its requirements and to detect errors. These errors can be of any type - Syntax errors, Run-time errors, Logical errors and Latent errors. Testing include necessary steps to detect all possible errors in the program. This can be done either at a module level known as unit testing or at program level known as integration testing. Debugging is a methodical process of finding and reducing the number of bugs in a computer program making it behave as expected. One simple way to find the location of the error is to use print statement to display the values of the variables. Once the location of the error is found, the error is corrected and debugging statement may be removed. 9. State The Differences Between Top down & Bottom Up Approaches? Answer: A top-down approach is essentially breaking down a system to gain insight i...

C Programming Interview Questions With Answers - Part I.

1. Explain Various Classes Of Datatypes Of C? Answer: Following are the major classes of data types in C language: Primary Data Types: Also, known as fundamental/basic data types. All C compilers support four basic data types namely: integer(int), character(char), floating(float), and double precision floating point (double). Then there are extended data types such as long int, double int. Derived Data Types: Also, known as secondary or user-defined data types. These data types, derived from basic data types, include arrays, pointer, structure, union, enum etc. 2. What Are Escape Sequences Characters? List Any Six Of Them. Answer: The characters which when used with output functions like printf( ), putc(), put() etc. helps in formatting the output are known as Escape sequence character. The following is a list of six escape sequences. \n Newline \t Horizontal Tab \v Vertical Tab \b Backspace \r Carriage Return \\ Backslash 3. What Do You Mean By Underflow ...