Welcome to our deep dive into C Programming! In this lesson, we'll explore the unique characteristics of C that make it a powerful and widely-used programming language. Let's get started!
C is a high-level, general-purpose programming language created by Dennis Ritchie in the 1970s. It serves as the foundation for many other modern programming languages, including C++, C#, and Java. C is known for its efficiency, portability, and versatility, making it an ideal choice for developing system software, drivers, and embedded systems.
C uses a simple syntax that is easy to learn and understand. It consists of:
Variables in C are used to store data. They have a name, type, and value.
int age; /* Declare an integer variable named "age" */
age = 25; /* Assign the value 25 to the variable "age" */C supports several data types:
int (e.g., int a = 10;)float (e.g., float b = 25.5;) and double (e.g., double c = 3.14;)char (e.g., char d = 'A';)int or _Bool (e.g., int e = 1; or _Bool f = 1;)Functions in C are used to perform a specific task.
void greet(char* name) {
printf("Hello, %s!\n", name);
}
int main() {
char name[] = "John";
greet(name);
return 0;
}C offers several control structures, including:
if (age >= 18) {
printf("You are an adult.\n");
}if (age >= 18) {
printf("You are an adult.\n");
} else {
printf("You are a minor.\n");
}int day = 3;
switch (day) {
case 1:
printf("Today is Monday.\n");
break;
case 2:
printf("Today is Tuesday.\n");
break;
// ...
}for (int i = 0; i < 10; i++) {
printf("%d\n", i);
}What is the purpose of a variable in C?
Stay tuned for the next lesson, where we'll dive deeper into C Programming and learn how to write our first C program! 🚀