+ All Categories
Home > Documents > top100cinterviewquestionsandanswers-140906024441-phpapp01

top100cinterviewquestionsandanswers-140906024441-phpapp01

Date post: 06-Nov-2015
Category:
Upload: prabakaran-ellaiyappan
View: 213 times
Download: 1 times
Share this document with a friend
Description:
C interview questions
103
hirist .com www.hirist.com TOP 100 INTERVIEW QUESTIONS & ANSWERS C
Transcript
  • hirist.comwww.hirist.com

    TOP 100INTERVIEW QUESTIONS & ANSWERS

    C

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Who invented C Language?

    2

    QUESTION

    Dennis Ritchie in 1972 developed a new language by inheriting the features of both BCPL and B and adding

    additional features. He named the language as just C

    ANSWER

    QUESTION 1

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are the features of C Langauges?

    3

    QUESTION

    In C one can write programs like that of high level languages as in COBOL, BASIC, FORTRAN etc. as well as it

    permits very close interaction with the inner workings of the computer.

    It is a general purpose programming language. It is usually called system programming language but equally

    suited to writing a variety of applications.

    It supports various data types

    It follows the programming style based on fundamental control flow constructions for structured programming

    Functions may be predefined or user defined and they may return values of basic types, structures, unions or

    pointers

    ANSWER

    QUESTION 2

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are the advantages of c language?

    4

    QUESTION

    Easy to write

    Rich set of operators and functions that are builtin

    Support for bitwise operation

    Flexible use of pointers

    Direct control over the hardware

    Ability to access BIOS/DOS routines

    Interacting using Interrupts

    Ability to write TSR programs

    Ability to create .COM files

    Ability to create library files (.LIB)

    Ability to write interface programs

    Incorporating assembly language in C program

    ANSWER

    QUESTION 3

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a header file?

    5

    QUESTION

    Header files provide the definitions and declarations for the library functions. Thus, each header file contains the

    library functions along with the necessary definitions and declarations. For example, stdio.h, math.h, stdlib.h,

    string.h etc.

    ANSWER

    QUESTION 4

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    List the different types of C tokens?

    6

    QUESTION

    Constants

    Identifiers

    Keywords

    Operators

    Special symbols

    Strings

    ANSWER

    QUESTION 5

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a constant? What are the different types of constants?

    7

    QUESTION

    A constant is a value that does not change during the program execution. A constant used in C does not occupy

    memory. There are five types of constants. They are:

    Integer constants

    Floating point constants

    Character constants

    String literals

    Enumeration constants

    ANSWER

    QUESTION 6

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are the different types of c instructions?

    8

    QUESTION

    There are basically three types of instructions in C are :

    Type Declaration Instruction

    Arithmetic Instruction

    Control Instruction

    ANSWER

    QUESTION 7

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Why C is called a middle level language?

    9

    QUESTION

    C combines the features of both Assembly Level Languages (Low Level Languages) and Higher Level Languages.

    For this reason, C is referred to as a Middle Level Language. The feature of ALLs is that of enabling us to develop

    system level programs and the features of HLLs are those of higher degree of readability and machine

    independence.

    ANSWER

    QUESTION 8

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the purpose of main() function?

    10

    QUESTION

    The function main() invokes other functions within it. It is the first function to be called when the program starts

    execution.

    It is the starting function.

    It returns an int value to the environment that called the program.

    Recursive call is allowed for main( ) also.

    It is a user-defined function.

    ANSWER

    QUESTION 9

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is meant by type specifiers?

    11

    QUESTION

    Type specifiers decide the amount of memory space occupied by a variable. In the ease of integral types; it also

    explicitly states the range of values that the object can hold.

    ANSWER

    QUESTION 10

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the difference between single charater constant and string constant?

    12

    QUESTION

    A single character constant consists of only one character and it is enclosed within a pair of single quotes.

    A string constant consists of one or more characters and it is enclosed within a pair of double quotes.

    ANSWER

    QUESTION 11

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a loop?

    13

    QUESTION

    A loop is a process to do a job repeatedly with possibly different data each time. The statements executed each time

    constitute the loop body, and each pass is called iteration. A condition must be present to terminate the loop.

    ANSWER

    QUESTION 12

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are the types of data types and explain?

    14

    QUESTION

    There are five basic Data types in C. These are :

    void: means nothing i.e. no data involvement in an action

    char: to work with all types of characters used in computer operations

    int: to work with an integer type of data in any computational work

    float: to work with the real type of data or scientific numbers in the exponential form

    double: to work with double precision of numbers when the approximation is very crucial.

    ANSWER

    QUESTION 13

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the general form of a C program?

    15

    QUESTION

    A C program begins with the preprocessor directives, in which the programmer would specify which header file and

    what constants (if any) to be used. This is followed by the main function heading. Within the main function lies the

    variable declaration and program statement.

    ANSWER

    QUESTION 14

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the difference between Call by Value and Call by Reference?

    16

    QUESTION

    When using Call by Value, you are sending the value of a variable as parameter to a function, whereas Call by

    Reference sends the address of the variable. Also, under Call by Value, the value in the parameter is not affected

    by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the

    process within the function.

    ANSWER

    QUESTION 15

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a stack?

    17

    QUESTION

    A stack is one form of a data structure. Data is stored in stacks using the FILO (First In Last Out) approach. At any

    particular instance, only the top of the stack is accessible, which means that in order to retrieve data that is stored

    inside the stack, those on the upper part should be extracted first. Storing data in a stack is also referred to as a

    PUSH, while data retrieval is referred to as a POP.

    ANSWER

    QUESTION 16

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the use of a \0 character?

    18

    QUESTION

    It is referred to as a terminating null character, and is used primarily to show the end of a string value.

    ANSWER

    QUESTION 17

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the difference between the = symbol and == symbol?

    19

    QUESTION

    The = symbol is often used in mathematical operations. It is used to assign a value to a given variable. On the other

    hand, the = = symbol, also known as equal to or equivalent to, is a relational operator that is used to compare

    two values

    ANSWER

    QUESTION 18

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the modulus operator?

    20

    QUESTION

    The modulus operator outputs the remainder of a division. It makes use of the percentage (%) symbol. For example:

    10 % 3 = 1, meaning when you divide 10 by 3, the remainder is 1.

    ANSWER

    QUESTION 19

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Which of the following operators is incorrect and why? ( >=,

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is syntax error?

    22

    QUESTION

    Syntax errors are associated with mistakes in the use of a programming language. It maybe a command that was

    misspelled or a command that must was entered in lowercase mode but was instead entered with an upper case

    character. A misplaced symbol, or lack of symbol, somewhere within a line of code can also lead to syntax error.

    ANSWER

    QUESTION 21

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Can I use int data type to store the value 32768? Why?

    23

    QUESTION

    No. int data type is capable of storing values from -32768 to 32767. To store 32768, you can use long int instead.

    You can also use unsigned int, assuming you dont intend to store negative values.

    ANSWER

    QUESTION 22

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    When is the void keyword used in a function?

    24

    QUESTION

    When declaring functions, you will decide whether that function would be returning a value or not. If that function will

    not return a value, such as when the purpose of a function is to display some outputs on the screen, then void is

    to be placed at the leftmost part of the function header. When a return value is expected after the function

    execution, the data type of the return value is placed instead of void.

    ANSWER

    QUESTION 23

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the significance of an algorithm to C programming?

    25

    QUESTION

    Before a program can be written, an algorithm has to be created first. An algorithm provides a step by step

    procedure on how a solution can be derived. It also acts as a blueprint on how a program will start and end,

    including what process and computations are involved.

    ANSWER

    QUESTION 24

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    How do you generate random numbers in C?

    26

    QUESTION

    Random numbers are generated in C using the rand() command. For example: anyNum = rand() will generate any

    integer number beginning from 0, assuming that anyNum is a variable of type integer.

    ANSWER

    QUESTION 25

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is debugging?

    27

    QUESTION

    Debugging is the process of identifying errors within a program. During program compilation, errors that are found

    will stop the program from executing completely. At this state, the programmer would look into the possible

    portions where the error occurred. Debugging ensures the removal of errors, and plays an important role in

    ensuring that the expected program output is met.

    ANSWER

    QUESTION 26

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What does the && operator do in a program code?

    28

    QUESTION

    The && is also referred to as AND operator. When using this operator, all conditions specified must be TRUE before

    the next action can be performed. If you have 10 conditions and all but 1 fails to evaluate as TRUE, the entire

    condition statement is already evaluated as FALSE.

    ANSWER

    QUESTION 27

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is || operator and how does it function in a program?

    29

    QUESTION

    The || is also known as the OR operator in C programming. When using || to evaluate logical conditions, any

    condition that evaluates to TRUE will render the entire condition statement as TRUE.

    ANSWER

    QUESTION 28

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What will be the outcome of the following conditional statement if the value of

    variable s is 10? s >=10 && s < 25 && s!=12

    30

    QUESTION

    The outcome will be TRUE. Since the value of s is 10, s >= 10 evaluates to TRUE because s is not greater than 10

    but is still equal to 10. s< 25 is also TRUE since 10 is less then 25. Just the same, s!=12, which means s is not

    equal to 12, evaluates to TRUE. The && is the AND operator, and follows the rule that if all individual conditions

    are TRUE, the entire statement is TRUE.

    ANSWER

    QUESTION 29

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is FIFO?

    31

    QUESTION

    In C programming, there is a data structure known as queue. In this structure, data is stored and accessed using

    FIFO format, or First-In-First-Out. A queue represents a line wherein the first data that was stored will be the first

    one that is accessible as well.

    ANSWER

    QUESTION 30

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    In C language, the variables NAME, name, and Name are all the same. TRUE or

    FALSE?

    32

    QUESTION

    FALSE. C language is a case sensitive language. Therefore, NAME, name and Name are three uniquely different

    variables.

    ANSWER

    QUESTION 31

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    When is a switch statement preferable over an if statement?

    33

    QUESTION

    The switch statement is best used when dealing with selections based on a single variable or expression. However,

    switch statements can only evaluate integer and character data types.

    ANSWER

    QUESTION 32

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is gets() function?

    34

    QUESTION

    The gets() function allows a full line data entry from the user. When the user presses the enter key to end the input,

    the entire line of characters is stored to a string variable. Note that the enter key is not included in the variable, but

    instead a null terminator \0 is placed after the last character.

    ANSWER

    QUESTION 33

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Difference between Syntax and logical error?

    35

    QUESTION

    Syntax error:

    These involves validation of syntax of language

    Compiler prints diagnostic message.

    Logical error:

    Logical error are caused by an incorrect algorithm or by a statement mistyped in such a way that it doesnt violet

    syntax of language.

    It is difficult to find.

    ANSWER

    QUESTION 34

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is static memory allocation?

    36

    QUESTION

    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.

    ANSWER

    QUESTION 35

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is dynamic memory allocation?

    37

    QUESTION

    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.

    ANSWER

    QUESTION 36

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Are Pointers Integer?

    38

    QUESTION

    No, Pointers are not integers. A pointer is an address. It is a positive number.

    ANSWER

    QUESTION 37

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    In header files whether functions are declared or defined?

    39

    QUESTION

    Functions are declared within header file. That is function prototypes exist in a header file, not function bodies. They

    are defined in library (lib).

    ANSWER

    QUESTION 38

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Difference between strdup and strcpy?

    40

    QUESTION

    Both copy a string. Strcpy wants a buffer to copy into. Strdup allocates a buffer using malloc(). Unlike strcpy(),

    strdup() is not specified by ANSI.

    ANSWER

    QUESTION 39

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is spaghetti programming?

    41

    QUESTION

    Spaghetti programming refers to codes that tend to get tangled and overlapped throughout the program. This

    unstructured approach to coding is usually attributed to lack of experience on the part of the programmer.

    Spaghetti programing makes a program complex and analyzing the codes difficult, and so must be avoided as

    much as possible.

    ANSWER

    QUESTION 40

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    In C programming, how do you insert quote characters ( and ) into the output

    screen?

    42

    QUESTION

    This is a common problem for beginners because quotes are normally part of a printf statement. To insert the quote

    character as part of the output, use the format specifiers (for single quote), and (for double quote).

    ANSWER

    QUESTION 41

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a nested loop?

    43

    QUESTION

    A nested loop is a loop that runs within another loop. Put it in another sense, you have an inner loop that is inside an

    outer loop. In this scenario, the inner loop is performed a number of times as specified by the outer loop. For each

    turn on the outer loop, the inner loop is first performed.

    ANSWER

    QUESTION 42

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Can the curly brackets { } be used to enclose a single line of code?

    44

    QUESTION

    While curly brackets are mainly used to group several lines of codes, it will still work without error if you used it for a

    single line. Some programmers prefer this method as a way of organizing codes to make it look clearer, especially

    in conditional statements.

    ANSWER

    QUESTION 43

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are compound statements?

    45

    QUESTION

    Compound statements are made up of two or more program statements that are executed together. This usually

    occurs while handling conditions wherein a series of statements are executed when a TRUE or FALSE is

    evaluated. Compound statements can also be executed within a loop. Curly brackets { } are placed before and

    after compound statements.

    ANSWER

    QUESTION 44

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a register variable?

    46

    QUESTION

    Register variables are stored in the CPU registers. Its default value is a garbage value. Scope of a register variable

    is local to the block in which it is defined. Lifetime is till control remains within the block in which the register

    variable is defined. Variable stored in a CPU register can always be accessed faster than the one that is stored in

    memory. Therefore, if a variable is used at many places in a program, it is better to declare its storage class as

    register

    Example: register int x=5;

    Variables for loop counters can be declared as register. Note that register keyword may be ignored by some

    compilers.

    ANSWER

    QUESTION 45

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is size of void pointer?

    47

    QUESTION

    Size of any type of pointer in c is independent of data type which is pointer is pointing i.e. size of all type of pointer

    (near) in c is two byte either it is char pointer, double pointer, function pointer or null pointer. Void pointer is not

    exception of this rule and size of void pointer is also two byte.

    ANSWER

    QUESTION 46

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are printf and scanf, call by reference or call by value?

    48

    QUESTION

    Printf : Call by value

    Scanf : Call by reference

    ANSWER

    QUESTION 47

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a const pointer?

    49

    QUESTION

    a const pointer means the pointer which represents the address of one value. so if you declare a pointer inside the

    function, it doesn't have scope outside the function. if it is also available to the outside function whenever we

    declare a pointer as const.

    ANSWER

    QUESTION 48

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Why does n++ execute much faster than n+1?

    50

    QUESTION

    n++ takes more than one instruction, ++n is faster. n++ has to store n, increment the variable and return n, while

    ++n increment n and return without storing the previous value of n.

    ANSWER

    QUESTION 49

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is modular Programming?

    51

    QUESTION

    If a program is large, it is subdivided into a number of smaller programs that are called modules or subprograms. If a

    complex problem is solved using more modules, this approach is known as modular programming.

    ANSWER

    QUESTION 51

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Why doesn't C support function overloading?

    52

    QUESTION

    Overloading is polymorphism which is one of the characteristics of Object oriented programming. C is not and object

    oriented language like C++ or Java. Therefore, no overloading, inheritance, etc.

    ANSWER

    QUESTION 51

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is an incomplete type?

    53

    QUESTION

    Incomplete types refers to pointers in which there is non availability of the implementation of the referenced location

    or it points to some location whose value is not available for modification.

    ANSWER

    QUESTION 52

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Explain the Difference between C and C++?

    54

    QUESTION

    C is the predecessor of C++. C++ is an Object Oriented, non-procedural language, unlike C, which is a procedural

    language. C++ treats all data and functional handling in terms of Objects and their relationships.

    ANSWER

    QUESTION 53

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is Nesting in C?

    55

    QUESTION

    Including one constructed inside another, is nesting. Nesting can be a structure inside another structure, an if-else

    statement within another, multiple while loops, one inside the other. Continuing our earlier example, if you have a

    collection of bikes, instead of grouping them separately, you can nest them within a main structure, which you can

    name Collection of Bikes.

    ANSWER

    QUESTION 54

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    How is calloc () different from malloc ()?

    56

    QUESTION

    The main difference between the two is that calloc (), when it is used to assign a block of memory, the allocated

    contents are initialized to 0. Malloc (), on the other hand, does not initialise the memory block it assigns. The

    memory just has random values left over from previous usage.

    ANSWER

    QUESTION 55

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are Destructors in C Language?

    57

    QUESTION

    Classifying a destructor you can call it a class object and it is called a destructor once it goes out of scope or gets

    deleted overtly. The job of a destructor is to put an end to objects being produced by a constructor. Just like the

    constructor you can consider destructor a functional member and it is specifically known by a class name.

    ANSWER

    QUESTION 56

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are the uses of a pointer?

    58

    QUESTION

    Pointer is used in the following cases

    i) It is used to access array elements

    ii) It is used for dynamic memory allocation.

    iii) It is used in Call by reference

    iv) It is used in data structures like trees, graph, linked list etc.

    ANSWER

    QUESTION 57

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a union?

    59

    QUESTION

    Union is a collection of heterogeneous data type but it uses efficient memory utilization technique by allocating

    enough memory to hold the largest member. Here a single area of memory contains values of different types at

    different time. A union can never be initialized.

    ANSWER

    QUESTION 58

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are macros? What are its advantages and disadvantages?

    60

    QUESTION

    Macros are abbreviations for lengthy and frequently used statements. When a macro is called the entire code is

    substituted by a single line though the macro definition is of several lines.

    The advantage of macro is that it reduces the time taken for control transfer as in case of function.

    The disadvantage of it is here the entire code is substituted so the program becomes lengthy if a macro is called

    several times.

    ANSWER

    QUESTION 59

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are enumerations?

    61

    QUESTION

    They are a list of named integer-valued constants. Example:enum color { black , orange=4, yellow, green, blue,

    violet }; This declaration defines the symbols black, orange, yellow, etc. to have the values 1, 4, 5, etc.

    The difference between an enumeration and a macro is that the enum actually declares a type, and therefore can

    be type checked.

    ANSWER

    QUESTION 60

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the use of typedef?

    62

    QUESTION

    The typedef help in easier modification when the programs are ported to another machine. A descriptive new name

    given to the existing data type may be easier to understand the code.

    ANSWER

    QUESTION 61

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the difference between Strings and Arrays?

    63

    QUESTION

    String is a sequence of characters ending with NULL .it can be treated as a one dimensional array of characters

    terminated by a NULL character.

    ANSWER

    QUESTION 62

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a normalized pointer, how do we normalize a pointer?

    64

    QUESTION

    It is a 32bit pointer, which has as much of its value in the segment registered as possible. Since a segment can start

    every 16bytes so the offset will have a value from 0 to F. for normalization convert the address into 20bit address

    then use the 16bit for segment address and 4bit for the offset address. Given a pointer 500D: 9407, we convert it

    to a 20bitabsolute address 549D7,Which then normalized to 549D:0007.

    ANSWER

    QUESTION 63

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is generic pointer in C?

    65

    QUESTION

    In C void* acts as a generic pointer. When other pointer types are assigned to generic pointer, conversions are

    applied automatically (implicit conversion).

    ANSWER

    QUESTION 64

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Difference between linker and linkage?

    66

    QUESTION

    Linker converts an object code into an executable code by linking together the necessary built in functions. The form

    and place of declaration where the variable is declared in a program determine the linkage of variable.

    ANSWER

    QUESTION 65

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a function?

    67

    QUESTION

    A large program is subdivided into a number of smaller programs or subprograms. Each subprogram specifies one

    or more actions to be performed for the larger program. Such sub programs are called functions.

    ANSWER

    QUESTION 66

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is an argument?

    68

    QUESTION

    An argument is an entity used to pass data from the calling to a called function.

    ANSWER

    QUESTION 67

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Write a program which employs Recursion?

    69

    QUESTION

    int fact(int n) { return n > 1 ? n * fact(n 1) : 1; }

    ANSWER

    QUESTION 68

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What do the c and v in argc and argv stand for?

    70

    QUESTION

    The c in argc(argument count) stands for the number of command line argument the program is invoked with and v

    in argv(argument vector) is a pointer to an array of character string that contain the arguments.

    ANSWER

    QUESTION 69

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are C identifiers?

    71

    QUESTION

    These are names given to various programming element such as variables, function, arrays.It is a combination of

    letter, digit and underscore.It should begin with letter. Backspace is not allowed.

    ANSWER

    QUESTION 70

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What do the functions atoi(), itoa() and gcvt() do?

    72

    QUESTION

    atoi() is a macro that converts integer to character.

    itoa() It converts an integer to string

    gcvt() It converts a floating point number to string

    ANSWER

    QUESTION 71

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    How is fopen() used ?

    73

    QUESTION

    The function fopen() returns a file pointer. Hence a file pointer is declared and it is assigned as

    FILE *fp;

    fp= fopen(filename,mode);

    filename is a string representing the name of the file and the mode represents:

    r for read operation

    w for write operation

    a for append operation

    r+,w+,a+ for update operation

    ANSWER

    QUESTION 72

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the purpose of ftell ?

    74

    QUESTION

    The function ftell() is used to get the current file represented by the file pointer.

    ftell(fp);

    returns a long integer value representing the current file position of the file pointed by the

    file pointer fp.If an error occurs ,-1 is returned.

    ANSWER

    QUESTION 73

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Discuss on pointer arithmetic?

    75

    QUESTION

    1. Assignment of pointers to the same type of pointers.

    2. Adding or subtracting a pointer and an integer.

    3. Subtracting or comparing two pointer.

    4. Incrementing or decrementing the pointers pointing to the elements of an array. When a pointer to an integer is

    incremented by one , the address is incremented by two. It is done automatically by the compiler.

    5. Assigning the value 0 to the pointer variable and comparing 0 with the pointer. The pointer having address 0

    points to nowhere at all.

    ANSWER

    QUESTION 74

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the invalid pointer arithmetic?

    76

    QUESTION

    i) adding ,multiplying and dividing two pointers.

    ii) Shifting or masking pointer.

    iii) Addition of float or double to pointer.

    iv) Assignment of a pointer of one type to a pointer of another type ?

    ANSWER

    QUESTION 75

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Can we initialize unions?

    77

    QUESTION

    ANSI Standard C allows an initializer for the first member of a union. There is no standard way of initializing any

    other member (nor, under a pre-ANSI compiler, is there generally any way of initializing a union at all).

    ANSWER

    QUESTION 76

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is Output of following c snippet?

    int main(){

    char *s="Abhas";

    printf("%s",s+ 2);

    getch();

    }

    78

    QUESTION

    Has. Explanation: In the above program role of %s is to display the string whose address is passed as an

    argument. This is how a standard printf statement works in c language. Now since we have passed s + 2 as an

    argument therefore first value of this expression is evaluated. Here s would refer to address of first character in

    string s. Now printf would get address of third character (address of first character + 2) as argument so it will

    display the string starting from third position. Hence output would be has.

    ANSWER

    QUESTION 77

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is difference between .com program and .exe program?

    79

    QUESTION

    Both .com and .exe program are executable program but .com program executes faster than .exe program. All

    drivers are .com program. .com file has higher preference than .exe.

    ANSWER

    QUESTION 78

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Describe turbo c Compiler?

    80

    QUESTION

    Turbo c is an IDE programming language created by Borland. Turbo C 3.0 is based on MS DOS operation system. It

    is one of the most popular c compilers. It uses 8086 microprocessor which is 16 bit microprocessor. It has 20

    address buses and 16 data bus. Its word length is two byte.

    ANSWER

    QUESTION 79

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Out of fgets() and gets() which function is safe to use and why?

    81

    QUESTION

    Fgets() is safer than gets(), because we can specify a maximum input length. Neither one is completely safe,

    because the compiler cant prove that programmer wont overflow the buffer he pass to fgets ().

    ANSWER

    QUESTION 80

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Differentiate between a for loop and a while loop?

    82

    QUESTION

    For executing a set of statements fixed number of times we use for loop while when the number of iterations to be

    performed is not known in advance we use while loop.

    ANSWER

    QUESTION 81

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Is there a built-in function in C that can be used for sorting data?

    83

    QUESTION

    Yes, use the qsort() function. It is also possible to create user defined functions for sorting, such as those based on

    the balloon sort and bubble sort algorithm.

    ANSWER

    QUESTION 82

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are the advantages and disadvantages of a heap?

    84

    QUESTION

    Storing data on the heap is slower than it would take when using the stack. However, the main advantage of using

    the heap is its flexibility. Thats because memory in this structure can be allocated and remove in any particular

    order. Slowness in the heap can be compensated if an algorithm was well designed and implemented.

    ANSWER

    QUESTION 83

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    How do you convert strings to numbers in C?

    85

    QUESTION

    You can write you own functions to do string to number conversions, or instead use Cs built in functions. You can

    use atof to convert to a floating point value, atoi to convert to an integer value, and atol to convert to a long integer

    value.

    ANSWER

    QUESTION 84

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Create a simple code fragment that will swap the values of two variables num1 and

    num2.

    86

    QUESTION

    int temp;

    temp = num1;

    num1 = num2;

    num2 = temp;

    ANSWER

    QUESTION 85

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the use of a semicolon (;) at the end of every program statement?

    87

    QUESTION

    It has to do with the parsing process and compilation of the code. A semicolon acts as a delimiter, so that the

    compiler knows where each statement ends, and can proceed to divide the statement into smaller elements for

    syntax checking.

    ANSWER

    QUESTION 86

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What does the characters r and w mean when writing programs that will make

    use of files?

    88

    QUESTION

    r means read and will open a file as input wherein data is to be retrieved. w means write, and will open a file

    for output. Previous data that was stored on that file will be erased.

    ANSWER

    QUESTION 87

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Which function in C can be used to append a string to another string?

    89

    QUESTION

    The strcat function. It takes two parameters, the source string and the string value to be appended to the source

    string.

    ANSWER

    QUESTION 88

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the difference between functions getch() and getche()?

    90

    QUESTION

    Both functions will accept a character input value from the user. When using getch(), the key that was pressed will

    not appear on the screen, and is automatically captured and assigned to a variable. When using getche(), the key

    that was pressed by the user will appear on the screen, while at the same time being assigned to a variable.

    ANSWER

    QUESTION 89

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What does the function toupper() do?

    91

    QUESTION

    It is used to convert any letter to its upper case mode. Toupper() function prototype is declared in . Note

    that this function will only convert a single character, and not an entire string.

    ANSWER

    QUESTION 90

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What are run-time errors?

    92

    QUESTION

    These are errors that occur while the program is being executed. One common instance wherein run-time errors can

    happen is when you are trying to divide a number by zero. When run-time errors occur, program execution will

    pause, showing which program line caused the error.

    ANSWER

    QUESTION 91

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Is this program statement valid? INT = 10.50;

    93

    QUESTION

    Assuming that INT is a variable of type float, this statement is valid. One may think that INT is a reserved word and

    must not be used for other purposes. However, recall that reserved words are express in lowercase, so the C

    compiler will not interpret this as a reserved word.

    ANSWER

    QUESTION 92

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is wrong with this program statement? void = 10;

    94

    QUESTION

    The word void is a reserved word in C language. You cannot use reserved words as a user-defined variable.

    ANSWER

    QUESTION 93

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What would happen to X in this expression: X += 15; (assuming the value of X is 5)

    95

    QUESTION

    X +=15 is a short method of writing X = X + 15, so if the initial value of X is 5, then 5 + 15 = 20.

    ANSWER

    QUESTION 94

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Not all reserved words are written in lowercase. TRUE or FALSE?

    96

    QUESTION

    FALSE. All reserved words must be written in lowercase; otherwise the C compiler would interpret this as

    unidentified and invalid.

    ANSWER

    QUESTION 95

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is floating point constants?

    97

    QUESTION

    Floating-point constants are numbers with decimal parts. A floating-point constants consists of :

    An integral part

    A decimal point

    A fractional part

    An exponent part

    An optional suffix

    ANSWER

    QUESTION 96

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is the difference between fread and fwrite function?

    98

    QUESTION

    The fread() function returns the number of items read. This value may be less than count if the end of the file is

    reached or an error occurs. The fwrite() function returns the number of items written. This value will equal count

    unless an error occurs.

    ANSWER

    QUESTION 97

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is meant by inheritance?

    99

    QUESTION

    Inheritance is the process by which objects of one class acquire properties of objects of another class.

    ANSWER

    QUESTION 98

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is a ternary operator in C?

    100

    QUESTION

    Perhaps the most unusual operator in C language is one called the conditional expression operator. Unlike all other

    operators in C which are either unary or binary operators the conditional expression operator is a ternary operator;

    that is, it takes three operands. The two symbols that are used to denote this operator are the question mark (?)

    and the colon (:). The first operand is placed before the ?, the second between the ? and the and the third after

    the:.

    ANSWER

    QUESTION 99

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    What is unary operator?

    101

    QUESTION

    The operators that act upon a single operand to produce a new value are known as unary operators.

    ANSWER

    QUESTION 100

  • For the hottest C jobs, please visit www.hirist.com

    hirist.com

    Resources

    102

    http://www.fresherventure.net/frequently-asked-c-language-interview-questions-and-answers/http://www.itechaleart.com/2014/06/top-100-c-interview-qa.htmlhttp://placement.freshersworld.com/power-preparation/technical-interview-questions/C-programming-answers-21419http://career.guru99.com/top-100-c-interview-questions-answers/http://www.slideshare.net/vineetkumarsaini/top-c-language-interview-questions-and-answerhttp://www.cquestions.com/2010/10/c-interview-questions-and-answers.htmlhttp://placementsindia.blogspot.com/2007/10/basic-c-interview-questions.htmlhttps://www.udemy.com/blog/c-programming-questions/http://crackaninterview.com/c-language-interview-questions/http://www.cwithabhas.com/2013/09/simple-c-interview-questions-for-mass.htmlhttp://www.freejobalert.com/c-interview-questions/2891/

  • www.hirist.com

    TOP 100INTERVIEW QUESTIONS & ANSWERS

    C


Recommended