Text Practice Mode
c language
created May 25th 2023, 20:26 by ANONYMOSYT
1
170 words
23 completed
0
Rating visible after 3 or more votes
00:00
#include <stdio.h>
int main() {
// Data types
int num = 10;
float pi = 3.14;
char letter = 'A';
double largeNum = 1234567890.1234567890;
// Control flow statements
if (num > 0) {
printf("Positive number\n");
} else {
printf("Negative number\n");
}
for (int i = 0; i < num; i++) {
printf("%d ", i);
}
printf("\n");
while (num > 0) {
printf("%d ", num);
num--;
}
printf("\n");
// Functions
int add(int a, int b) {
return a + b;
}
int sum = add(5, 3);
printf("Sum: %d\n", sum);
// Pointers
int* ptr = #
printf("Value: %d\n", *ptr);
// Arrays
int arr[] = {1, 2, 3, 4, 5};
for (int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) {
printf("%d ", arr[i]);
}
printf("\n");
// Structures
struct Point {
int x;
int y;
};
struct Point p;
p.x = 10;
p.y = 20;
printf("Point: (%d, %d)\n", p.x, p.y);
// File handling
FILE* file = fopen("example.txt", "w");
if (file != NULL) {
fputs("Hello, World!", file);
fclose(file);
}
return 0;
}
int main() {
// Data types
int num = 10;
float pi = 3.14;
char letter = 'A';
double largeNum = 1234567890.1234567890;
// Control flow statements
if (num > 0) {
printf("Positive number\n");
} else {
printf("Negative number\n");
}
for (int i = 0; i < num; i++) {
printf("%d ", i);
}
printf("\n");
while (num > 0) {
printf("%d ", num);
num--;
}
printf("\n");
// Functions
int add(int a, int b) {
return a + b;
}
int sum = add(5, 3);
printf("Sum: %d\n", sum);
// Pointers
int* ptr = #
printf("Value: %d\n", *ptr);
// Arrays
int arr[] = {1, 2, 3, 4, 5};
for (int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) {
printf("%d ", arr[i]);
}
printf("\n");
// Structures
struct Point {
int x;
int y;
};
struct Point p;
p.x = 10;
p.y = 20;
printf("Point: (%d, %d)\n", p.x, p.y);
// File handling
FILE* file = fopen("example.txt", "w");
if (file != NULL) {
fputs("Hello, World!", file);
fclose(file);
}
return 0;
}
saving score / loading statistics ...