Makindo Medical Notes"One small step for man, one large step for Makindo" |
|
---|---|
Download all this content in the Apps now Android App and Apple iPhone/Pad App | |
MEDICAL DISCLAIMER: The contents are under continuing development and improvements and despite all efforts may contain errors of omission or fact. This is not to be used for the assessment, diagnosis, or management of patients. It should not be regarded as medical advice by healthcare workers or laypeople. It is for educational purposes only. Please adhere to your local protocols. Use the BNF for drug information. If you are unwell please seek urgent healthcare advice. If you do not accept this then please do not use the website. Makindo Ltd. |
C is a high-level and general-purpose programming language that is widely used for system and application software. It provides low-level access to memory and system resources, making it ideal for developing operating systems, embedded systems, and performance-critical applications.
// This is a single-line comment
/* This is a multi-line comment spanning multiple lines */
#include#define PI 3.14
int main() { printf("Hello, World!"); return 0; }
int age = 25; float height = 5.9; double pi = 3.14159; char initial = 'A';
if (age > 18) { printf("Adult"); } else { printf("Minor"); }
switch (initial) { case 'A': printf("Grade A"); break; case 'B': printf("Grade B"); break; default: printf("Other Grade"); }
for (int i = 0; i < 5; i++) { printf("%d ", i); } int j = 0; while (j < 5) { printf("%d ", j); j++; } int k = 0; do { printf("%d ", k); k++; } while (k < 5);
int add(int a, int b) { return a + b; } int main() { int sum = add(5, 3); printf("Sum: %d", sum); return 0; }
void greet() { printf("Hello, World!"); } int main() { greet(); return 0; }
int numbers[5] = {1, 2, 3, 4, 5}; printf("First element: %d", numbers[0]);
int x = 10; int *ptr = &x; printf("Value of x: %d", *ptr); // Output: Value of x: 10
int arr[3] = {10, 20, 30}; int *p = arr; printf("%d ", *p); // Output: 10 printf("%d ", *(p + 1)); // Output: 20 printf("%d ", *(p + 2)); // Output: 30
struct Person { char name[50]; int age; }; int main() { struct Person person1; strcpy(person1.name, "Alice"); person1.age = 30; printf("Name: %s, Age: %d", person1.name, person1.age); return 0; }
FILE *file = fopen("example.txt", "r"); if (file != NULL) { char line[100]; while (fgets(line, sizeof(line), file)) { printf("%s", line); } fclose(file); }
FILE *file = fopen("example.txt", "w"); if (file != NULL) { fprintf(file, "Hello, World!"); fclose(file); }
int *ptr = (int *)malloc(5 * sizeof(int)); if (ptr != NULL) { for (int i = 0; i < 5; i++) { ptr[i] = i + 1; } free(ptr); }
#define PI 3.14 #define SQUARE(x) ((x) * (x)) int main() { printf("PI: %f\n", PI); printf("Square of 5: %d", SQUARE(5)); return 0; }
#define DEBUG int main() { #ifdef DEBUG printf("Debug mode\n"); #else printf("Release mode\n"); #endif return 0; }
#includeprintf("Hello, World!");
#includeint *ptr = (int *)malloc(sizeof(int) * 5); free(ptr);
#includechar str1[20] = "Hello"; char str2[20]; strcpy(str2, str1); // Copies str1 to str2 printf("%s", str2);
#includedouble result = sqrt(16.0); printf("Square root: %f", result);
C is a powerful and versatile programming language that provides low-level access to memory and system resources. Understanding its basic syntax, control structures, functions, data structures, file I/O, memory management, and standard libraries is essential for developing efficient and effective programs. C is widely used in system programming, embedded systems, and performance-critical applications.