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

C_Programming_Flashcards

The document provides a series of questions and answers related to the C programming language, covering topics such as program structure, data types, loops, functions, pointers, and file handling. Key concepts include the differences between keywords and identifiers, the use of escape sequences, and the definitions of recursion and multi-dimensional arrays. It also explains practical programming tasks like checking for palindromes and calculating factorials.

Uploaded by

sscam254
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

C_Programming_Flashcards

The document provides a series of questions and answers related to the C programming language, covering topics such as program structure, data types, loops, functions, pointers, and file handling. Key concepts include the differences between keywords and identifiers, the use of escape sequences, and the definitions of recursion and multi-dimensional arrays. It also explains practical programming tasks like checking for palindromes and calculating factorials.

Uploaded by

sscam254
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/ 2

1. Q: What is the structure of a C program?

A: Includes: Header files, main function, variable declarations, and statements.

2. Q: What is the difference between a keyword and an identifier?

A: Keyword: Reserved word in C (e.g., int, return). Identifier: User-defined name for

variables/functions.

3. Q: What are escape sequences?

A: Special characters starting with '\', like \n (newline), \t (tab), \0 (null).

4. Q: What are the basic data types in C and their ranges?

A: int, float, char, double. Example: int (-32,768 to 32,767) on 16-bit systems.

5. Q: What is operator associativity?

A: Direction in which operators of same precedence are evaluated. Most are left to right.

6. Q: Difference between while and do-while loop?

A: while checks before execution, do-while checks after executing once.

7. Q: When is a for loop preferred over a while loop?

A: When the number of iterations is known beforehand.

8. Q: What is the use of break and continue?

A: break exits a loop, continue skips to next iteration.

9. Q: What is recursion?

A: A function calling itself to solve a sub-problem.

10. Q: How do you define and call a function in C?

A: Define: returnType name(params) { }, Call: name(arguments);

11. Q: How are arrays and pointers similar?


A: Array name acts like a pointer to its first element.

12. Q: What is a multi-dimensional array?

A: An array of arrays, e.g., int matrix[3][3];

13. Q: What is a null pointer?

A: A pointer that doesn't point to any memory location, initialized as NULL.

14. Q: How are structures defined in C?

A: Using struct keyword with data members inside braces.

15. Q: Difference between structure and union?

A: Struct allocates memory for all members, union shares memory.

16. Q: How do you open a file in C?

A: Using fopen("filename", "mode"); Modes: r, w, a, r+, etc.

17. Q: How to include one file in another?

A: Using #include "filename.h" or #include <stdio.h>.

18. Q: How to check for a palindrome number?

A: Reverse the number and compare with original.

19. Q: How to calculate factorial using recursion?

A: Base case: if(n==0) return 1; else return n*factorial(n-1);

20. Q: How to sum diagonal elements of an n x n matrix?

A: Sum elements where row index equals column index.

You might also like