#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
#include <stdio.h>
int main() {
char name[] = "Santosh";
int age = 25;
printf("Name: %s\n", name);
printf("Age: %d\n", age);
return 0;
}
#include <stdio.h>
int main() {
int a = 10, b = 5;
printf("Addition: %d\n", a + b);
printf("Subtraction: %d\n", a - b);
printf("Multiplication: %d\n", a * b);
printf("Division: %d\n", a / b);
printf("Modulus: %d\n", a % b);
return 0;
}
#include <stdio.h>
int main() {
int age = 20;
if (age >= 18) {
printf("Eligible for voting\n");
} else {
printf("Not eligible for voting\n");
}
return 0;
}
#include <stdio.h>
int main() {
// For loop example
for (int i = 1; i <= 5; i++) {
printf("Santosh is learning C - Iteration: %d\n", i);
}
// While loop example
int count = 1;
while (count <= 3) {
printf("Dhruv is exploring C - Attempt: %d\n", count);
count++;
}
return 0;
}
#include <stdio.h>
void greet(char name[]) {
printf("Hello, %s! Welcome to Pynfinity.\n", name);
}
int main() {
greet("Santosh");
greet("Kumar");
return 0;
}
#include <stdio.h>
int main() {
char names[4][10] = {"Santosh", "Kumar", "Dhruv", "Pynfinity"};
for (int i = 0; i < 4; i++) {
printf("Name: %s\n", names[i]);
}
return 0;
}
#include <stdio.h>
int main() {
int num = 10;
int *ptr = #
printf("Value of num: %d\n", num);
printf("Address of num: %p\n", &num);
printf("Value stored at ptr: %d\n", *ptr);
return 0;
}
#include <stdio.h>
#include <string.h>
int main() {
char str[20] = "Pynfinity Channel";
printf("String: %s\n", str);
printf("Length of string: %lu\n", strlen(str));
// Copy string
char copy[20];
strcpy(copy, str);
printf("Copied string: %s\n", copy);
return 0;
}
#include <stdio.h>
struct Person {
char name[20];
int age;
};
int main() {
struct Person p1 = {"Santosh", 25};
struct Person p2 = {"Kumar", 30};
printf("Name: %s, Age: %d\n", p1.name, p1.age);
printf("Name: %s, Age: %d\n", p2.name, p2.age);
return 0;
}
#include <stdio.h>
int main() {
FILE *file = fopen("example.txt", "w");
if (file == NULL) {
printf("Could not open file\n");
return 1;
}
fprintf(file, "This is a test file created by Santosh.\n");
fclose(file);
// Reading from file
file = fopen("example.txt", "r");
char ch;
while ((ch = fgetc(file)) != EOF) {
putchar(ch);
}
fclose(file);
return 0;
}