-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.c
More file actions
40 lines (32 loc) · 769 Bytes
/
simple.c
File metadata and controls
40 lines (32 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
// Function to add two integers
int add(int a, int b) {
return a + b;
}
// Function to print an array
void printArray(int arr[], int size) {
for (int i = 0; i < size; i++) {
printf("%d ", arr[i]);
}
printf("\n");
}
// Main function
int main() {
int x = 5;
int y = 10;
int result = add(x, y);
printf("Result of add: %d\n", result);
int arr[5] = {1, 2, 3, 4, 5};
printArray(arr, 5);
// Conditional check
if (result > 10) {
printf("Result is greater than 10\n");
} else {
printf("Result is 10 or less\n");
}
// Loop example
for (int i = 0; i < 3; i++) {
printf("Loop iteration: %d\n", i);
}
return 0;
}