0% found this document useful (0 votes)
5 views

shortQ&A.ctp

The document provides a concise Q&A format covering fundamental concepts of the C programming language, including its definition, basic data types, functions, pointers, memory management, and various operators. Key differences between related concepts, such as structs and unions, as well as functions like malloc() and calloc(), are also highlighted. Overall, it serves as a quick reference guide for essential C programming topics.

Uploaded by

Gladio Nexus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

shortQ&A.ctp

The document provides a concise Q&A format covering fundamental concepts of the C programming language, including its definition, basic data types, functions, pointers, memory management, and various operators. Key differences between related concepts, such as structs and unions, as well as functions like malloc() and calloc(), are also highlighted. Overall, it serves as a quick reference guide for essential C programming topics.

Uploaded by

Gladio Nexus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Short Q\A

1. *What is C programming?*

- C is a high-level programming language that was developed in the 1970s. It is widely used for system programming,
developing operating systems, and embedded systems due to its performance and control over system resources.

2. *Who developed the C language?*

- C was developed by Dennis Ritchie at Bell Labs in the early 1970s.

3. *What are the basic data types in C?*

- Basic data types are int, char, float, and double.

4. *What is a pointer?*

- A pointer is a variable that stores the memory address of another variable.

5. **What is the use of the printf() function?**

- The printf() function is used to output/display information to the standard output (usually the screen).

6. **What is the use of the scanf() function?**

- The scanf() function is used to take input from the user.

7. **What is the difference between ++i and i++?**

- ++i is a pre-increment operation (increments first, then uses the value), while i++ is a post-increment operation (uses
the current value first, then increments).

8. *What is a function in C?*

- A function is a block of code that performs a specific task, and can be called upon to execute from other parts of the
program.
9. *What is recursion?*

- Recursion is a programming technique where a function calls itself.

10. *What is an array?*

- An array is a collection of elements of the same data type stored in contiguous memory locations.

11. *What is a string in C?*

- A string is an array of characters, terminated by a null character (\0).

12. *What is a structure in C?*

- A structure is a user-defined data type in C that allows grouping different data types together.

13. *What is a union?*

- A union is a data structure similar to a structure, but it can store only one member's value at a time because all
members share the same memory location.

14. **What is the difference between struct and union?**

- In a struct, all members have separate memory locations, while in a union, all members share the same memory
location.

15. *What are header files in C?*

- Header files contain function declarations and macros and are included in the program using the #include directive.

16. *What is a macro?*

- A macro is a fragment of code that has been given a name. It is defined using #define and can be reused throughout
the program.

17. **What is the difference between #include <filename> and #include "filename"?**

- #include <filename> is used for system header files, while #include "filename" is used for user-defined header files.
18. *What is a file pointer in C?*

- A file pointer is a pointer to a file structure, and it is used to work with files in C. It is declared as FILE *fp.

19. **What is the difference between malloc() and calloc()?**

- malloc() allocates a single block of memory, while calloc() allocates multiple blocks and initializes them to zero.

20. *What is dynamic memory allocation?*

- Dynamic memory allocation allows memory to be allocated during runtime using functions like malloc(), calloc(),
realloc(), and free().

21. *What is a dangling pointer?*

- A dangling pointer is a pointer that points to memory that has been freed or deleted.

22. *What is segmentation fault?*

- A segmentation fault occurs when a program tries to access memory that it is not allowed to, such as dereferencing a
null or invalid pointer.

23. *What are the storage classes in C?*

- The four storage classes in C are auto, static, extern, and register.

24. **What is the difference between auto and static variables?**

- auto variables have local scope and are destroyed after function execution. static variables retain their value across
function calls and have a global lifetime.

25. *What is the scope of a variable?*

- Scope refers to the region of the program where a variable can be accessed.

26. *What is typecasting?*


- Typecasting is the process of converting one data type into another.

27. **What is the purpose of the return statement in C?**

- The return statement terminates the execution of a function and returns a value to the calling function.

28. **What is the difference between break and continue?**

- break exits a loop entirely, while continue skips the current iteration and moves to the next iteration of the loop.

29. *What is an infinite loop?*

- An infinite loop is a loop that continues to execute without a terminating condition, such as while(1).

30. *What is an inline function?*

- Inline functions are small functions whose code is inserted directly into the calling code to reduce function call
overhead.

31. **What is the difference between for and while loops?**

- A for loop is used when the number of iterations is known beforehand, while a while loop is used when the number
of iterations is not known.

32. *What is a conditional operator?*

- The conditional operator (?:) is a shorthand for an if-else statement, used to evaluate a condition and return one of
two values.

33. *What is a pointer to a function?*

- A pointer to a function stores the address of a function, allowing the function to be called indirectly.

34. *What is a preprocessor directive?*

- Preprocessor directives are instructions processed before the actual compilation starts. Examples include #include,
#define, and #if.
35. *What is an enumerated type in C?*

- An enumerated type (enum) is a user-defined data type consisting of named integer constants.

36. **What is sizeof in C?**

- sizeof is a compile-time operator that returns the size, in bytes, of a data type or variable.

37. *What are bitwise operators in C?*

- Bitwise operators operate on bits and include &, |, ^, ~, <<, and >>.

38. *What is a command-line argument?*

- Command-line arguments are passed to the program at runtime through the command line and are accessed via
argc (argument count) and argv (argument vector).

39. **What is the difference between exit() and return?**

- exit() terminates the entire program, while return only exits the current function.

40. **What is the volatile keyword?**

- volatile tells the compiler that the value of a variable may change unexpectedly and should not be optimized.

41. **What is the purpose of the const keyword?**

- The const keyword is used to declare variables whose values cannot be changed after initialization.

42. **What is the use of the extern keyword?**

- The extern keyword is used to declare a variable that is defined in another file or a function that will be linked at
runtime.

43. *What are wild pointers?*

- Wild pointers are pointers that have not been initialized and point to arbitrary memory locations.
44. **What is the purpose of the NULL pointer?**

- A NULL pointer is used to indicate that a pointer does not point to any valid memory location.

45. **What is the difference between NULL and void pointer?**

- A NULL pointer is a pointer that points to nothing, while a void pointer is a generic pointer that can point to any data
type.

46. *What is meant by type qualifiers?*

- Type qualifiers, such as const, volatile, and restrict, provide additional information about variables, like their
mutability or how they are accessed.

47. *What is an lvalue and rvalue in C?*

- An lvalue refers to a memory location that can appear on the left-hand side of an assignment, while an rvalue is a
data value that can appear on the right-hand side.

48. *What are formatted and unformatted I/O functions in C?*

- Formatted I/O functions like printf() and scanf() allow input/output with specific formatting. Unformatted I/O
functions like getchar() and putchar() handle input/output of raw data without formatting.

49. **What is the difference between memcpy() and memmove()?**

- memcpy() copies memory between non-overlapping areas, while memmove() safely copies memory between
potentially overlapping areas.

50. **What is the use of the free() function in C?**

- The free() function is used to deallocate memory that was dynamically allocated using malloc() or calloc().

You might also like