Untitled Deck Flashcards
Who developed the C programming language and when?
C was developed by Dennis Ritchie at Bell Labs in 1972.
What is the main purpose of the C programming language?
C is a general-purpose, procedural programming language used for system programming, developing operating systems, and applications.
What are the basic data types in C?
The basic data types are:
- int (integer)
- float (floating-point number)
- char (character)
- double (double-precision floating-point number).
What is the role of the main()
function in a C program?
The main()
function is the entry point of every C program. The program execution starts from the main()
function.
What are comments in C, and how are they written?
Comments are used to make the code more readable and are ignored during execution.
- Single-line comment: // Comment here
- Multi-line comment: /* Comment here */
.
What are the different types of loops in C?
The types of loops are:
- for loop
- while loop
- do-while loop.
What is the difference between break
and continue
?
-
break
: Terminates the loop or switch statement immediately. -
continue
: Skips the rest of the current loop iteration and moves to the next iteration.
What is a switch
statement?
A switch
statement is a control statement that executes a block of code based on the value of an expression, typically using case
labels.
What is the difference between if
and else if
?
-
if
evaluates a condition and executes a block if the condition is true. -
else if
is used to test multiple conditions after an initialif
.
What is a function in C?
A function is a block of code that performs a specific task and can be reused.
What are the types of functions in C?
-
Library functions: Predefined functions like
printf()
andscanf()
. - User-defined functions: Functions created by the programmer.
What are function prototypes in C?
A function prototype declares the function name, return type, and parameters before its definition to inform the compiler about the function.
What is recursion in C?
Recursion is when a function calls itself directly or indirectly to solve smaller instances of a problem.
What is a pointer in C?
A pointer is a variable that stores the address of another variable.
How do you declare a pointer in C?
A pointer is declared using the *
symbol. Example: int *ptr;