Important Questions of ' C ' Asked in Technical Interview and Online Test





1 . What are the features of C language?

Ans : C programming language is middle level language and developed by Dennis Ritchie at Bell Laboratories during 1972. It has the following features: High portability, pointer implementation, simplicity, flexibility and memory managements etc.

2. What are the difference between C and C++?
Ans :

    C is procedural programming language whereas C++ is Object Oriented Programming(OOPS) Language
    C language uses top-down approach and C++ used bottom-up approach
    C language does not support namespace while C++ support it.
    In C language, polymorphism is not support and C++ supports polymorphism.
    Overloading is supported in C++ and C language has not support overloading.

3. What are header files in C?

Ans : Header files in C Language contains declaration of functions, macros and other library files with directive #include. Most commonly used header files in C language are #include<stdio.h>, #include<conio.h> etc.

4. What is the purpose of using main() in C?

Ans : In C programming language, execution of program start from main0 and it is also used to invokes(calls) other functions in the program. It is user-defined function.

5. What is the different between string and character?

Ans : Character stores a single value(alphabet) like x,y and 2 whereas string is used to array(more than 1 character) of character(alphabets) like xyz.

6. What is structure and unions?

Ans : Structure are used to group different variable under the same name with different memory allocation(memory address) whereas union also group different variables under same name but it allocate same memory location.

7. Name some header files in C?

Ans : Some of most commonly used header files in C programming Language: <stdio.h>, <conio.h>, <math.h>, <string.h> etc.

8. What is pointer?

Ans : Pointers are variables which stores the address(memory location) of another variable. Pointers are can be used as reference variable and to access data stored in arrays.

9. What is the use of typedef?

Ans : In C programming language, typedef(type definition) is used to create own variable type.

10. What is Syntax Error?

Ans : Syntax error may be cause due to incorrectly writing programming code and not following programming syntax efficiently. Syntax errors are found during compilation of program.

11 . How Variable are different from constant?

Ans : Avariables can change it value while constant cannot change it value once it is declared as constant. For example, pi=3.14 or dozen is equal to 12 are constant.

12. What is the difference between Array and Pointer?

Ans : Array has sequence(contiguous) of pre-located memory location for it elements of similar data types whereas pointer stores address of variables.Pointers use * operator to access memory address and array uses subscript variables.

13. What is Array?

Ans : Array is a collection of similar data types. Array is a variable which stores(hold) multiple elements(variables) of same data types.

14. What is dangling pointer?

Ans : When a variable is deleted or no longer located(memory freed) in a memory location, but the pointer still points to that memory location(address). Such pointers are called as dangling pointers.

15. What is enumeration?

Ans : In C programming, enumeration is used to defined fixed number of constants. Enum values are final and cannot be changed once it values is created. E.g. enum WeekDays{ Mon, Tue, Wed, Thur, Fri, Sat, Sun}

16. What is null pointer?

Ans : Null pointer is a special reserved pointer which point nowhere(to nothing) or has value null(typically has value 0).

17. What are Volatile variable?

Ans : A Volatile variable tell compiler that its value may change at any time e.g. it is used in I/0 mapped location.

18. What is union?

Ans : Union in C language are almost similar to structure(which group dilfiferent variable under same name) but the only different is memory allocation, as all the variable(members) are stored in same memory address.

19. What is the use of unions?

Ans : Union are useful for saving lots of memory allocation(address) as all the variables are stored in same address.

20. Difference between static memory allocation and dynamic memory allocation?

Ans : In static memory allocation, memory allocation is occurs during compile time whereas in dynamic memory allocation is done during runtime.

21. Difference between Arrays and linked list?

Ans : Array has contiguous memory location whereas linked list contains nodes(which points to next list). Linked list can be easily grown in size and in arrays it is quite difficult. In arrays, elements cannot be added additionally once there are declared whereas in linked list is can be done easily.

22. What are the uses of pointers?
Ans :

    Pointer in C programming language is used for :
    Dynamic memory allocation
    Access stored data in arrays
    Used in call by reference
    Memory management optimization



23. What is the difference between call by value and call by reference?
Ans : In call by value, values of variables are called(send) as a parameter to function whereas in call by reference address of variable is called(send).

24. What is malloc()?

Ans : The malloc() function reserves or allocate a bytes of memory(specified or requested memory) from heap. Here malloc() means Memory Allocation.

25. What is calloc()?

Ans : Calloc() allocates block of memory for array of elements of certain size . calloc is abbreviated for contiguous memory.

26. What is macro?

Ans : Macro are identifiers which is piece(statement or fragment) of code. Whenever macro is used (pre-processor see macro) in the program, it is replace by text or string(statement or fragment code).

27. What is the use of sizeof() operator?


Ans : The sizeof() operator in C language is used to display the size of data types in bytes.

28. What is getch()?

Ans : Getch() reads the character without displaying or echoing it. getch() process the characterjust after pressing key,not letting you to press enter key.

29. What is the different between getch() and getche() functions?

Ans : Getch() reads the characterjust after pressing the key without echoing(disp|aying) while getcheo reads and display the characterjust after pressing any key.

30. Can we create own header files? How?
Ans : Yes, we can create our own header files in C language.
Need to write any code which you want to make header file
int sumof(int x, int y)
Now save the above program with sumof.h in bin or include folder
Accessing own header file
#include<stdio.h>
#include<conio.h>
#include<sumof.h>//own header file
Voidmain()
{
int x,y,z;
printf("Enter the values for x and y:");
scanf(“%d%d",&x,&y);
z=sumof(x,y)
printf("T he sum of x and y is: %d",z);
{
return(a+b)
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment