Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
jobsiit.com
Top 80
C Programming
Interview Questions and Answers
jobsiit.comInterview Questions and Answers
ANSWER
What is C language?
C is a structured, procedural programming language t...
jobsiit.comInterview Questions and Answers
ANSWER
Who invented C language?
In 1972, Dennis Ritchie developed a new languag...
jobsiit.comInterview Questions and Answers
ANSWER
What are the features of C language?
• The C compiler combines the capab...
jobsiit.comInterview Questions and Answers
ANSWER
What are the uses of C language?
C is often used for "system programming...
jobsiit.comInterview Questions and Answers
ANSWER
What do you mean by a Constant?
Constants are also like normal variables...
jobsiit.comInterview Questions and Answers
ANSWER
What are the Rules of constructing constants?
• An integer constant must...
jobsiit.comInterview Questions and Answers
ANSWER
What do you mean by a Variable?
• Variables are simply names used to ref...
jobsiit.comInterview Questions and Answers
ANSWER
What are the rules for naming a C variable?
• Variable name must begin w...
jobsiit.comInterview Questions and Answers
ANSWER
What are data types? Name the different types of data types in C languag...
jobsiit.comInterview Questions and Answers
ANSWER
What is the purpose of the String() function?
C Strings are nothing but ...
jobsiit.comInterview Questions and Answers
ANSWER
What do you mean by tokens and keywords?
• Tokens are the basic building...
jobsiit.comInterview Questions and Answers
ANSWER
What is the difference between constant and volatile keyword?
Constants ...
jobsiit.comInterview Questions and Answers
ANSWER
What are the different types of operators?
C language offers many types ...
jobsiit.comInterview Questions and Answers
ANSWER
What is the difference between operators and expressions?
• An operator ...
jobsiit.comInterview Questions and Answers
ANSWER
What is a loop?
Loops are used to repeat a block of code. Being able to ...
jobsiit.comInterview Questions and Answers
ANSWER
What are the rules for constructing a identifier name in C?
• The first ...
jobsiit.comInterview Questions and Answers
ANSWER
What is syntax error?
Syntax error is a mistake in the syntax of some st...
jobsiit.comInterview Questions and Answers
ANSWER
What is a local block?
A local block is any portion of a C program that ...
jobsiit.comInterview Questions and Answers
ANSWER
Should variables be stored in local block?
The use of local blocks for s...
jobsiit.comInterview Questions and Answers
ANSWER
When is switch statement better than multiple if statements?
Switch stat...
jobsiit.comInterview Questions and Answers
ANSWER
Can the last case of a switch statement skip including the break?
Even t...
jobsiit.comInterview Questions and Answers
ANSWER
What is the difference between goto and long jmp( ) and setjmp()?
A goto...
jobsiit.comInterview Questions and Answers
ANSWER
What is a rvalue?
rvalue can be defined as an expression that can be ass...
jobsiit.comInterview Questions and Answers
ANSWER
Can an array be an 1value?
The answer to this question is no, because a ...
jobsiit.comInterview Questions and Answers
ANSWER
When is the "void" keyword used in a function?
• The void keyword allows...
jobsiit.comInterview Questions and Answers
ANSWER
What are the difference between malloc() and calloc()?
• Calloc is used ...
jobsiit.comInterview Questions and Answers
ANSWER
Is the left to right or right to left order gauranteed for operator prec...
jobsiit.comInterview Questions and Answers
ANSWER
Specify the different types of decision control statements in C.
• If
• ...
jobsiit.comInterview Questions and Answers
ANSWER
What are the advantages of using pointers?
• Pointers are more efficient...
jobsiit.comInterview Questions and Answers
ANSWER
What is a static variable?
A static variable is a variable that has been...
jobsiit.comInterview Questions and Answers
ANSWER
What is the difference between declaring a variable and defining a varia...
jobsiit.comInterview Questions and Answers
ANSWER
Where is an auto variable stored?
They are stored in main memory. Memory...
jobsiit.comInterview Questions and Answers
ANSWER
How are errors handled in C language?
• C programming does not provide d...
jobsiit.comInterview Questions and Answers
ANSWER
What do you mean by a storage class? Name the storage classes which can ...
jobsiit.comInterview Questions and Answers
ANSWER
What are the rules for constructing identifier name in C.
Rules for cons...
jobsiit.comInterview Questions and Answers
ANSWER
What are case control statement? Name the types of case control statemen...
jobsiit.comInterview Questions and Answers
ANSWER
What is the scope of register and static variables?
• Register is used t...
jobsiit.comInterview Questions and Answers
ANSWER
What is the use of printf and scanf function?
• printf() function is use...
jobsiit.comInterview Questions and Answers
ANSWER
What is debugging?
Debugging is the process of locating and fixing or by...
jobsiit.comInterview Questions and Answers
ANSWER
What is FIFO and LIFO?
• FIFO (first-in, first-out) is an approach to ha...
jobsiit.comInterview Questions and Answers
ANSWER
What is the && operator and how does it function in a program code?
• Th...
jobsiit.comInterview Questions and Answers
ANSWER
What is the difference between “break” and continue statements?
• The br...
jobsiit.comInterview Questions and Answers
ANSWER
Elaborate the buffer manipulation function?
• Buffer manipulation functi...
jobsiit.comInterview Questions and Answers
ANSWER
What is call by reference in functions?
• The call by reference method o...
jobsiit.comInterview Questions and Answers
ANSWER
Which is a better option in C Language – Macros or Functions?
Macros are...
jobsiit.comInterview Questions and Answers
ANSWER
What is a memory leak? How can it be avoided?
• Memory leak occurs when ...
jobsiit.comInterview Questions and Answers
ANSWER
What is gets( ) function?
In the C Programming Language, the gets functi...
jobsiit.comInterview Questions and Answers
ANSWER
What do you mean by a nested loop?
• A nested loop is a loop within a lo...
jobsiit.comInterview Questions and Answers
ANSWER
What is Dynamic memory allocation in C? Name the dynamic allocation func...
jobsiit.comInterview Questions and Answers
ANSWER
What are the uses of Static local variables?
• Static variables declared...
jobsiit.comInterview Questions and Answers
ANSWER
What do you mean by Modular Programming?
Modular programming is a softwa...
jobsiit.comInterview Questions and Answers
ANSWER
What are Unions and what does it reflect in C?
• Union is a user defined...
jobsiit.comInterview Questions and Answers
ANSWER
What are the applications of Unions?
• Unions can be useful in many situ...
jobsiit.comInterview Questions and Answers
ANSWER
What is the difference between “Char a” and “Char a[1]”?
• “char a” repr...
jobsiit.comInterview Questions and Answers
ANSWER
What do you understand by enumerations?
• The process of allocating memo...
jobsiit.comInterview Questions and Answers
ANSWER
What are macros? What are the advantages and disadvantages of macros?
A ...
jobsiit.comInterview Questions and Answers
ANSWER
What are Arrays? Name the types of C arrays.
Array is a collection of va...
jobsiit.comInterview Questions and Answers
ANSWER
What is typedef?
• typedef is a keyword in the C and C++ programming lan...
jobsiit.comInterview Questions and Answers
ANSWER
What is the difference between strings and arrays?
• Array is a collecti...
jobsiit.comInterview Questions and Answers
ANSWER
What is generic pointer in C?
When a variable is declared as being a poi...
jobsiit.comInterview Questions and Answers
ANSWER
What do you understand by a function?
• A function is a group of stateme...
jobsiit.comInterview Questions and Answers
ANSWER
What is hashing?
• Hashing is the transformation of a string of characte...
jobsiit.comInterview Questions and Answers
ANSWER
What techniques are used for debugging?
Techniques used for debugging:
•...
jobsiit.comInterview Questions and Answers
ANSWER
Do you know pragma directive in C?
The Pragma directive is the method sp...
jobsiit.comInterview Questions and Answers
ANSWER
What is the output of printf(“%d”)?
When we write printf(“%d”) the compi...
jobsiit.comInterview Questions and Answers
ANSWER
Can include files be nested?
Yes. Include files can be nested any number...
jobsiit.comInterview Questions and Answers
ANSWER
How many levels deep can include files be nested?
• Even though there is...
jobsiit.comInterview Questions and Answers
ANSWER
What are compilers?
A compiler is a computer program that transforms sou...
jobsiit.comInterview Questions and Answers
ANSWER
What is #line used for?
#line lets you modify the compiler's line number...
jobsiit.comInterview Questions and Answers
ANSWER
What is the benefit of using enum to declare a constant?
The main benefi...
jobsiit.comInterview Questions and Answers
ANSWER
What is the difference between printf() and sprintf()?
• Sprintf() write...
jobsiit.comInterview Questions and Answers
ANSWER
How can we reduce the file size of executable?
The file size of executab...
jobsiit.comInterview Questions and Answers
ANSWER
What is a stack?
Stack is an area of memory that holds all local variabl...
jobsiit.comInterview Questions and Answers
ANSWER
What are the four types of stack in C?
Four types of stack in C are:
• B...
jobsiit.comInterview Questions and Answers
ANSWER
Where are command line arguments given?
Command-line arguments are given...
jobsiit.comInterview Questions and Answers
ANSWER
What is nested structure?
Structure written inside another structure is ...
jobsiit.comInterview Questions and Answers
ANSWER
When should the volatile modifier be used?
The volatile modifier is a di...
jobsiit.comInterview Questions and Answers
ANSWER
What is a file header?
• A header file is a file with extension .h which...
jobsiit.comInterview Questions and Answers
ANSWER
What is Type casting?
Type casting is a way to convert a variable from o...
jobsiit.comInterview Questions and Answers
ANSWER
What do you mean by Recursion and recursive call of the function?
Recurs...
• http://www.cprogramming.com
• http://ecomputernotes.com/what-is-c
• http://www.tutorialspoint.com/cprogramming/
• http:/...
Upcoming SlideShare
Loading in …5
×

Top 80 C-Language Interview Questions and Answers

jobsiit.com - These are the top 80 C-Language interview question with answers which will help you to crack your job interview. These questions were asked in TCS, Infosys, Wipro, HCL and Cognizant. You can download this file absolutely free.

JobsIIT.com, being steered by a team of IIT/NITians, understands the requirements of jobseekers of all colleges and top-notch recruiters equally well. We started as the only portal in India exclusively focused on connecting all engineering talent with the premium recruiters and have since provided our services to 700+ recruiters so far.

  • Login to see the comments

Top 80 C-Language Interview Questions and Answers

  1. 1. jobsiit.com Top 80 C Programming Interview Questions and Answers
  2. 2. jobsiit.comInterview Questions and Answers ANSWER What is C language? C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. QUESTION 1 For Computer Science related jobs visit www.jobsiit.com
  3. 3. jobsiit.comInterview Questions and Answers ANSWER Who invented C language? In 1972, Dennis Ritchie developed a new language by combining features from BCPL and B and adding some additional features naming the language as C. QUESTION 2 For Computer Science related jobs visit www.jobsiit.com
  4. 4. jobsiit.comInterview Questions and Answers ANSWER What are the features of C language? • The C compiler combines the capabilities of an assembly language with features of a high-level language. • Programs Written in C are efficient and fast. This is due to its variety of data type and powerful operators. • C is highly portable this means that programs once written can be run on another machines with little or no modification. • Another important feature of C program, is its ability to extend itself. QUESTION 3 For Computer Science related jobs visit www.jobsiit.com
  5. 5. jobsiit.comInterview Questions and Answers ANSWER What are the uses of C language? C is often used for "system programming", including implementing operating systems and embedded system applications, due to a combination of desirable characteristics such as code portability and efficiency. QUESTION 4 For Computer Science related jobs visit www.jobsiit.com
  6. 6. jobsiit.comInterview Questions and Answers ANSWER What do you mean by a Constant? Constants are also like normal variables. But, only difference is, their values can’t be modified by the program once they are defined. • They refer to fixed values • They are also called as literals • They may be belonging to any of the data type QUESTION 5 For Computer Science related jobs visit www.jobsiit.com
  7. 7. jobsiit.comInterview Questions and Answers ANSWER What are the Rules of constructing constants? • An integer constant must have at least one digit • It must not have a decimal point • It can either be positive or negative • No commas or blanks are allowed within an integer constant • A real constant must have at least one digit • The maximum length of a character constant is 1 character QUESTION 6 For Computer Science related jobs visit www.jobsiit.com
  8. 8. jobsiit.comInterview Questions and Answers ANSWER What do you mean by a Variable? • Variables are simply names used to refer to some location in memory a location that holds a value with which we are working. • It may help to think of variables as a placeholder for a value. • You can think of a variable as being equivalent to its assigned value. QUESTION 7 For Computer Science related jobs visit www.jobsiit.com
  9. 9. jobsiit.comInterview Questions and Answers ANSWER What are the rules for naming a C variable? • Variable name must begin with letter or underscore • Variables are case sensitive • They can be constructed with digits, letters • No special symbols are allowed other than underscore • Sum, height, _value are some examples for variable name QUESTION 8 For Computer Science related jobs visit www.jobsiit.com
  10. 10. jobsiit.comInterview Questions and Answers ANSWER What are data types? Name the different types of data types in C language. Data types are defined as the data storage format that a variable can store a data to perform a specific operation. Types of data types: • Basic data types- int, char, float, double • Enumeration data type- enum • Derived data type- pointer, array, structure, union • Void data type- void QUESTION 9 For Computer Science related jobs visit www.jobsiit.com
  11. 11. jobsiit.comInterview Questions and Answers ANSWER What is the purpose of the String() function? C Strings are nothing but array of characters ended with null character (‘0’). This null character indicates the end of the string. Strings are always enclosed by double quotes. QUESTION 10 For Computer Science related jobs visit www.jobsiit.com
  12. 12. jobsiit.comInterview Questions and Answers ANSWER What do you mean by tokens and keywords? • Tokens are the basic buildings blocks in C language which are constructed together to write a C program. Each and every smallest individual units in a C program are known as Tokens. • Keywords are pre-defined words in a C compiler. Each keyword is meant to perform a specific function in a C program. QUESTION 11 For Computer Science related jobs visit www.jobsiit.com
  13. 13. jobsiit.comInterview Questions and Answers ANSWER What is the difference between constant and volatile keyword? Constants are also like normal variables. But, only difference is, their values can’t be modified by the program once they are defined. • They refer to fixed values • They are also called as literals When a variable is defined as volatile, the program may not change the value of the variable explicitly. • These variable values might keep on changing • They have no explicit assignment to the program QUESTION 12 For Computer Science related jobs visit www.jobsiit.com
  14. 14. jobsiit.comInterview Questions and Answers ANSWER What are the different types of operators? C language offers many types of operators. They are: 1. Arithmetic operators 2. Assignment operators 3. Relational operators 4. Logical operators 5. Bit wise operators 6. Conditional operators 7. Special operators QUESTION 13 For Computer Science related jobs visit www.jobsiit.com
  15. 15. jobsiit.comInterview Questions and Answers ANSWER What is the difference between operators and expressions? • An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. • An expression is a combination of explicit values, constants, variables, operators, and functions that are interpreted according to the particular rules of precedence. QUESTION 14 For Computer Science related jobs visit www.jobsiit.com
  16. 16. jobsiit.comInterview Questions and Answers ANSWER What is a loop? Loops are used to repeat a block of code. Being able to have your program repeatedly execute a block of code is one of the most basic but useful tasks in programming - many programs or websites that produce extremely complex output are really only executing a single task many times. QUESTION 15 For Computer Science related jobs visit www.jobsiit.com
  17. 17. jobsiit.comInterview Questions and Answers ANSWER What are the rules for constructing a identifier name in C? • The first character of the variable name must either be alphabet or underscore • No commas and blanks are allowed in the variable name • No special symbols other than underscore are allowed in the variable name • Avoid creating long variable name as it adds to your typing effort QUESTION 16 For Computer Science related jobs visit www.jobsiit.com
  18. 18. jobsiit.comInterview Questions and Answers ANSWER What is syntax error? Syntax error is a mistake in the syntax of some strange sequence of characters or tokens that is intended to be stated in a particular programming language. QUESTION 17 For Computer Science related jobs visit www.jobsiit.com
  19. 19. jobsiit.comInterview Questions and Answers ANSWER What is a local block? A local block is any portion of a C program that is enclosed by the left brace ({) and the right brace (}). A C function contains left and right braces, and therefore anything between the two braces is contained in a local block. An if statement or a switch statement can also contain braces, so the portion of code between these two braces would be considered a local block. QUESTION 18 For Computer Science related jobs visit www.jobsiit.com
  20. 20. jobsiit.comInterview Questions and Answers ANSWER Should variables be stored in local block? The use of local blocks for storing variables is unusual and therefore should be avoided, with only rare exceptions. One of these exceptions would be for debugging purposes, when you might want to declare a local instance of a global variable to test within your function. You also might want to use a local block when you want to make your program more readable in the current context. QUESTION 19 For Computer Science related jobs visit www.jobsiit.com
  21. 21. jobsiit.comInterview Questions and Answers ANSWER When is switch statement better than multiple if statements? Switch statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type. QUESTION 20 For Computer Science related jobs visit www.jobsiit.com
  22. 22. jobsiit.comInterview Questions and Answers ANSWER Can the last case of a switch statement skip including the break? Even though the last case of a switch statement does not require a break statement at the end, you should add break statements to all cases of the switch statement, including the last case. You should do so primarily because your program has a strong chance of being maintained by someone other than you who might add cases but neglect to notice that the last case has no break statement. QUESTION 21 For Computer Science related jobs visit www.jobsiit.com
  23. 23. jobsiit.comInterview Questions and Answers ANSWER What is the difference between goto and long jmp( ) and setjmp()? A goto statement implements a local jump of program execution, and the longjmp() and setjmp() functions implement a nonlocal, or far, jump of program execution. Generally, a jump in execution of any kind should be avoided because it is not considered good programming practice to use such statements as goto and longjmp in your program. QUESTION 22 For Computer Science related jobs visit www.jobsiit.com
  24. 24. jobsiit.comInterview Questions and Answers ANSWER What is a rvalue? rvalue can be defined as an expression that can be assigned to an lvalue. The rvalue appears on the right side of an assignment statement. QUESTION 23 For Computer Science related jobs visit www.jobsiit.com
  25. 25. jobsiit.comInterview Questions and Answers ANSWER Can an array be an 1value? The answer to this question is no, because a n array is composed of several separate array elements that cannot be treated as a whole for assignment purposes. QUESTION 24 For Computer Science related jobs visit www.jobsiit.com
  26. 26. jobsiit.comInterview Questions and Answers ANSWER When is the "void" keyword used in a function? • The void keyword allows you to define a function that returns no data. • Functions that do not return any value are sometimes referred to as procedures or subroutines. • The sub keyword is an alias for void. • Both of these keywords can only be used when declaring or defining a function. QUESTION 25 For Computer Science related jobs visit www.jobsiit.com
  27. 27. jobsiit.comInterview Questions and Answers ANSWER What are the difference between malloc() and calloc()? • Calloc is used to allocate a block of memory, the allocated region is initialized to zeroes. • Malloc does not touch the contents of the allocated block of memory, which means it contains garbage values. QUESTION 26 For Computer Science related jobs visit www.jobsiit.com
  28. 28. jobsiit.comInterview Questions and Answers ANSWER Is the left to right or right to left order gauranteed for operator precedence? The simple answer to this question is neither. The C language does not always evaluate left-to-right or right-to-left. Generally, function calls are evaluated first, followed by complex expressions and then simple expressions. QUESTION 27 For Computer Science related jobs visit www.jobsiit.com
  29. 29. jobsiit.comInterview Questions and Answers ANSWER Specify the different types of decision control statements in C. • If • If else • Nested if QUESTION 28 For Computer Science related jobs visit www.jobsiit.com
  30. 30. jobsiit.comInterview Questions and Answers ANSWER What are the advantages of using pointers? • Pointers are more efficient in handling arrays and data tables • They can be used to return multiple values from a function via function arguments • Pointers permit references to functions • Pointers allow C to support dynamic memory management • Pointers reduce length and complexity of programs QUESTION 29 For Computer Science related jobs visit www.jobsiit.com
  31. 31. jobsiit.comInterview Questions and Answers ANSWER What is a static variable? A static variable is a variable that has been allocated statically—whose lifetime or "extent" extends across the entire run of the program. QUESTION 30 For Computer Science related jobs visit www.jobsiit.com
  32. 32. jobsiit.comInterview Questions and Answers ANSWER What is the difference between declaring a variable and defining a variable? • When you declare a variable, a function, or even a class all you are doing is saying: there is something with this name, and it has this type. • Defining something means providing all of the necessary information to create that thing in its entirety. QUESTION 31 For Computer Science related jobs visit www.jobsiit.com
  33. 33. jobsiit.comInterview Questions and Answers ANSWER Where is an auto variable stored? They are stored in main memory. Memory is allocated to an automatic variable when the block which contains it is called and it is de-allocated at the completion of its block execution. QUESTION 32 For Computer Science related jobs visit www.jobsiit.com
  34. 34. jobsiit.comInterview Questions and Answers ANSWER How are errors handled in C language? • C programming does not provide direct support for error handling but being a system programming language, it provides you access at lower level in the form of return values. • C programmer can check the returned values and can take appropriate action depending on the return value. • Developer should set error to 0 at the time of initialization of the program. QUESTION 33 For Computer Science related jobs visit www.jobsiit.com
  35. 35. jobsiit.comInterview Questions and Answers ANSWER What do you mean by a storage class? Name the storage classes which can be used in a C Program? A storage class in C is an attribute that tells us where the variable would be stored, what will be the initial value of the variable if no value is assigned to that variable. Four types of storage classes are: • Automatic storage class • Register storage class • Static storage class • External storage class QUESTION 34 For Computer Science related jobs visit www.jobsiit.com
  36. 36. jobsiit.comInterview Questions and Answers ANSWER What are the rules for constructing identifier name in C. Rules for constructing identifier name in C: • First character should be an alphabet or underscore • Succeeding characters might be digits or letter • Punctuation and special characters aren’t allowed except underscore • Identifiers should not be keywords QUESTION 35 For Computer Science related jobs visit www.jobsiit.com
  37. 37. jobsiit.comInterview Questions and Answers ANSWER What are case control statement? Name the types of case control statements in C language. The statements which are used to execute only specific block of statements in a series of blocks are called case control statements. There are 4 types of case control statements in C language. They are: • switch • break • continue • goto QUESTION 36 For Computer Science related jobs visit www.jobsiit.com
  38. 38. jobsiit.comInterview Questions and Answers ANSWER What is the scope of register and static variables? • Register is used to define local variables that should be stored in a register instead of RAM. • Static is the default storage class for global variables. The two variables count and road both have a static storage class. QUESTION 37 For Computer Science related jobs visit www.jobsiit.com
  39. 39. jobsiit.comInterview Questions and Answers ANSWER What is the use of printf and scanf function? • printf() function is used to print the “character, string, float, integer, octal and hexadecimal values” onto the output screen. • scanf() function is used to read character, string, numeric data from the keyboard. QUESTION 38 For Computer Science related jobs visit www.jobsiit.com
  40. 40. jobsiit.comInterview Questions and Answers ANSWER What is debugging? Debugging is the process of locating and fixing or bypassing bugs (errors) in computer program code or the engineering of a hardware device. QUESTION 39 For Computer Science related jobs visit www.jobsiit.com
  41. 41. jobsiit.comInterview Questions and Answers ANSWER What is FIFO and LIFO? • FIFO (first-in, first-out) is an approach to handling program work requests from queues or stacks so that the oldest request is handled next. • LIFO (last-in, first-out) is an approach in which the most recent request is handled next and the oldest request doesn't get handled. QUESTION 40 For Computer Science related jobs visit www.jobsiit.com
  42. 42. jobsiit.comInterview Questions and Answers ANSWER What is the && operator and how does it function in a program code? • The && is also known as AND operator and returns the boolean value true if both operands are true and returns false. • The operands are implicitly converted to type bool prior to evaluation, and the result is of type bool. • Logical AND has left-to-right associativity. QUESTION 41 For Computer Science related jobs visit www.jobsiit.com
  43. 43. jobsiit.comInterview Questions and Answers ANSWER What is the difference between “break” and continue statements? • The break statement is used to exit the current loop before its normal ending. • The continue statement resumes iteration of a enclosing for, while, until or select loop. QUESTION 42 For Computer Science related jobs visit www.jobsiit.com
  44. 44. jobsiit.comInterview Questions and Answers ANSWER Elaborate the buffer manipulation function? • Buffer manipulation functions in C work on the address of the memory block rather than the values inside the address. • Example programs for memset(), memcpy(), memmove(), memcmp(), memicmp() and memchr() functions are given below. QUESTION 43 For Computer Science related jobs visit www.jobsiit.com
  45. 45. jobsiit.comInterview Questions and Answers ANSWER What is call by reference in functions? • The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. • Inside the function, the address is used to access the actual argument used in the call. QUESTION 44 For Computer Science related jobs visit www.jobsiit.com
  46. 46. jobsiit.comInterview Questions and Answers ANSWER Which is a better option in C Language – Macros or Functions? Macros are more faster and efficient as compared to functions but complex programming cannot be handled by macros so whether to use macros or functions depends on the priority as well as use. QUESTION 45 For Computer Science related jobs visit www.jobsiit.com
  47. 47. jobsiit.comInterview Questions and Answers ANSWER What is a memory leak? How can it be avoided? • Memory leak occurs when programmers create a memory in heap and forget to delete it. • To avoid memory leaks, memory allocated on heap should always be freed when no longer needed. QUESTION 46 For Computer Science related jobs visit www.jobsiit.com
  48. 48. jobsiit.comInterview Questions and Answers ANSWER What is gets( ) function? In the C Programming Language, the gets function reads characters from the stdin stream and stores them in s. The gets function returns s. QUESTION 47 For Computer Science related jobs visit www.jobsiit.com
  49. 49. jobsiit.comInterview Questions and Answers ANSWER What do you mean by a nested loop? • A nested loop is a loop within a loop, an inner loop within the body of an outer one. • How this works is that the first pass of the outer loop triggers the inner loop, which executes to completion. Then the second pass of the outer loop triggers the inner loop again. QUESTION 48 For Computer Science related jobs visit www.jobsiit.com
  50. 50. jobsiit.comInterview Questions and Answers ANSWER What is Dynamic memory allocation in C? Name the dynamic allocation functions. • The process of allocating memory during program execution is called dynamic memory allocation. C language offers 4 dynamic memory allocation functions: • malloc() • calloc() • realloc() • free() QUESTION 49 For Computer Science related jobs visit www.jobsiit.com
  51. 51. jobsiit.comInterview Questions and Answers ANSWER What are the uses of Static local variables? • Static variables declared at block scope are initialized the first time control passes through their declaration. • On all further calls, the declaration is skipped. QUESTION 50 For Computer Science related jobs visit www.jobsiit.com
  52. 52. jobsiit.comInterview Questions and Answers ANSWER What do you mean by Modular Programming? Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality. QUESTION 51 For Computer Science related jobs visit www.jobsiit.com
  53. 53. jobsiit.comInterview Questions and Answers ANSWER What are Unions and what does it reflect in C? • Union is a user defined data type. In union, all members share the same memory location. • For example in the following C program, both x and y share the same location. QUESTION 52 For Computer Science related jobs visit www.jobsiit.com
  54. 54. jobsiit.comInterview Questions and Answers ANSWER What are the applications of Unions? • Unions can be useful in many situations where we want to use same memory for two ore more members. • For example, suppose we want to implement a binary tree data structure where each leaf node has a double data value, while each internal node has pointers to two children, but no data. QUESTION 53 For Computer Science related jobs visit www.jobsiit.com
  55. 55. jobsiit.comInterview Questions and Answers ANSWER What is the difference between “Char a” and “Char a[1]”? • “char a” represents a character variable and “char a[1]” represents a char array of size 1. • If we print value of char a, we get ASCII value of the character (if %d is used). And if we print value of char a[1], we get address of the only element in array. QUESTION 54 For Computer Science related jobs visit www.jobsiit.com
  56. 56. jobsiit.comInterview Questions and Answers ANSWER What do you understand by enumerations? • The process of allocating memory during program execution is called dynamic memory allocation. • An enumeration is a user-defined type that consists of a set of named integral constants that are known as enumerators. QUESTION 55 For Computer Science related jobs visit www.jobsiit.com
  57. 57. jobsiit.comInterview Questions and Answers ANSWER What are macros? What are the advantages and disadvantages of macros? A macro is a way to automate a task or procedure which you perform on a regular basis. • Advantage: A large number of task or action can be recorded in a single macro • Disadvantage: If something needs to be changed in the macro, the whole macro must be re-recorded QUESTION 56 For Computer Science related jobs visit www.jobsiit.com
  58. 58. jobsiit.comInterview Questions and Answers ANSWER What are Arrays? Name the types of C arrays. Array is a collection of variables belongings to the same data type. You can store group of data of same data type in an array. Types of C arrays: • One dimensional array • Multi dimensional array QUESTION 57 For Computer Science related jobs visit www.jobsiit.com
  59. 59. jobsiit.comInterview Questions and Answers ANSWER What is typedef? • typedef is a keyword in the C and C++ programming languages. • The purpose of typedef is to form complex types from more-basic machine types and assign simpler names to such combinations. QUESTION 58 For Computer Science related jobs visit www.jobsiit.com
  60. 60. jobsiit.comInterview Questions and Answers ANSWER What is the difference between strings and arrays? • Array is a collection of variables belongings to the same data type. You can store group of data of same data type in an array. • String is traditionally a sequence of characters, either as a literal constant or as some kind of variable. QUESTION 59 For Computer Science related jobs visit www.jobsiit.com
  61. 61. jobsiit.comInterview Questions and Answers ANSWER What is generic pointer in C? When a variable is declared as being a pointer to type void it is known as a generic pointer. QUESTION 60 For Computer Science related jobs visit www.jobsiit.com
  62. 62. jobsiit.comInterview Questions and Answers ANSWER What do you understand by a function? • A function is a group of statements that together perform a task. • Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. QUESTION 61 For Computer Science related jobs visit www.jobsiit.com
  63. 63. jobsiit.comInterview Questions and Answers ANSWER What is hashing? • Hashing is the transformation of a string of characters into a usually shorter fixed- length value or key that represents the original string. • Hashing is used to index and retrieve items in a database. QUESTION 62 For Computer Science related jobs visit www.jobsiit.com
  64. 64. jobsiit.comInterview Questions and Answers ANSWER What techniques are used for debugging? Techniques used for debugging: • Use compiler’s features • Read the fine module • Printf ( ) debugging • Code grinding • Assertion QUESTION 63 For Computer Science related jobs visit www.jobsiit.com
  65. 65. jobsiit.comInterview Questions and Answers ANSWER Do you know pragma directive in C? The Pragma directive is the method specified by the C standard for providing additional information to the compiler, beyond what is conveyed in the language itself. QUESTION 64 For Computer Science related jobs visit www.jobsiit.com
  66. 66. jobsiit.comInterview Questions and Answers ANSWER What is the output of printf(“%d”)? When we write printf(“%d”) the compiler will print the value of x. But as there is nothing after %d so compiler will show in output window garbage value. QUESTION 65 For Computer Science related jobs visit www.jobsiit.com
  67. 67. jobsiit.comInterview Questions and Answers ANSWER Can include files be nested? Yes. Include files can be nested any number of times. As long as you use precautionary measures, you can avoid including the same file twice. QUESTION 66 For Computer Science related jobs visit www.jobsiit.com
  68. 68. jobsiit.comInterview Questions and Answers ANSWER How many levels deep can include files be nested? • Even though there is no limit to the number of levels of nested include files you can have, your compiler might run out of stack space while trying to include high number of files. • This number varies according to your hardware configuration and possibly your compiler. QUESTION 67 For Computer Science related jobs visit www.jobsiit.com
  69. 69. jobsiit.comInterview Questions and Answers ANSWER What are compilers? A compiler is a computer program that transforms source code written in a programming language into another computer language (the target language, often having a binary form known as object code). QUESTION 68 For Computer Science related jobs visit www.jobsiit.com
  70. 70. jobsiit.comInterview Questions and Answers ANSWER What is #line used for? #line lets you modify the compiler's line number and (optionally) the file name output for errors and warnings. QUESTION 69 For Computer Science related jobs visit www.jobsiit.com
  71. 71. jobsiit.comInterview Questions and Answers ANSWER What is the benefit of using enum to declare a constant? The main benefit of using enum is that if you don't initialize your constants, each one would have a unique value. The first would be zero and the rest would then count upwards. QUESTION 70 For Computer Science related jobs visit www.jobsiit.com
  72. 72. jobsiit.comInterview Questions and Answers ANSWER What is the difference between printf() and sprintf()? • Sprintf() writes data to the character array. • Printf() writes data to the standard output device. QUESTION 71 For Computer Science related jobs visit www.jobsiit.com
  73. 73. jobsiit.comInterview Questions and Answers ANSWER How can we reduce the file size of executable? The file size of executable can be reduced with the help of dynamic linking for libraries. QUESTION 72 For Computer Science related jobs visit www.jobsiit.com
  74. 74. jobsiit.comInterview Questions and Answers ANSWER What is a stack? Stack is an area of memory that holds all local variables and parameters used by any function, and remembers the order in which functions are called so that function returns occur correctly. QUESTION 73 For Computer Science related jobs visit www.jobsiit.com
  75. 75. jobsiit.comInterview Questions and Answers ANSWER What are the four types of stack in C? Four types of stack in C are: • Block scope • Function scope • File scope • Program scope QUESTION 74 For Computer Science related jobs visit www.jobsiit.com
  76. 76. jobsiit.comInterview Questions and Answers ANSWER Where are command line arguments given? Command-line arguments are given after the name of a program in command-line operating systems like DOS or Linux, and are passed in to the program from the operating system. QUESTION 75 For Computer Science related jobs visit www.jobsiit.com
  77. 77. jobsiit.comInterview Questions and Answers ANSWER What is nested structure? Structure written inside another structure is called as nesting of two structures. QUESTION 76 For Computer Science related jobs visit www.jobsiit.com
  78. 78. jobsiit.comInterview Questions and Answers ANSWER When should the volatile modifier be used? The volatile modifier is a directive to the compiler’s optimizer that operations involving this variable should not be optimized in certain ways. QUESTION 77 For Computer Science related jobs visit www.jobsiit.com
  79. 79. jobsiit.comInterview Questions and Answers ANSWER What is a file header? • A header file is a file with extension .h which contains C function declarations and macro definitions and to be shared between several source files. • There are two types of header files: the files that the programmer writes and the files that come with your compiler. QUESTION 78 For Computer Science related jobs visit www.jobsiit.com
  80. 80. jobsiit.comInterview Questions and Answers ANSWER What is Type casting? Type casting is a way to convert a variable from one data type to another data type. For example, if you want to store a long value into a simple integer then you can type cast long to int. QUESTION 79 For Computer Science related jobs visit www.jobsiit.com
  81. 81. jobsiit.comInterview Questions and Answers ANSWER What do you mean by Recursion and recursive call of the function? Recursion is the process of repeating items in a self-similar way. Same applies in programming languages as well where if a programming allows you to call a function inside the same function that is called recursive call of the function as follows. QUESTION 80 For Computer Science related jobs visit www.jobsiit.com
  82. 82. • http://www.cprogramming.com • http://ecomputernotes.com/what-is-c • http://www.tutorialspoint.com/cprogramming/ • http://fresh2refresh.com/c • http://searchwindowsserver.techtarget.com/definition/C • http://www.studytonight.com/c • en.wikibooks.org/wiki/C_Programming/Variables • http://www.cprogramming.com/tutorial/c • http://www.learnconline.com • http://www.indiabix.com/technical/c/the-c-language-basics • http://ecomputernotes.com/what-is-c • http://www.programming-techniques.com JobsIITResources For Computer Science related jobs visit www.jobsiit.com

×