C Programming Codes
C Programming Codes || Quizzes || DSA Learn along with the community Any queries admin - @Pradeep_saii
Ko'proq ko'rsatish📈 Telegram kanali C Programming Codes analitikasi
C Programming Codes (@c_programming_codes) Ingliz til segmentidagi kanali faol ishtirokchi. Hozirda hamjamiyat 13 431 obunachidan iborat bo'lib, Texnologiyalar & Aralashmalar toifasida 9 534-o'rinni va Hindiston mintaqasida 32 075-o'rinni egallagan.
📊 Auditoriya ko‘rsatkichlari va dinamika
невідомо sanasidan buyon loyiha tez o‘sib, 13 431 obunachiga ega bo‘ldi.
11 Iyun, 2026 dagi oxirgi ma’lumotlarga ko‘ra kanal barqaror faollikka ega. Oxirgi 30 kunda obunachilar soni -239 ga, so‘nggi 24 soatda esa -9 ga o‘zgardi va umumiy qamrov yuqori darajada qolmoqda.
- Tasdiqlash holati: Tasdiqlanmagan
- Jalb etish (ER): Auditoriya o‘rtacha 9.78% darajada jalb etiladi. Nashrdan keyingi dastlabki 24 soatda kontent odatda umumiy obunachilar sonining N/A% ini tashkil etuvchi reaksiyalarni to‘playdi.
- Post qamrovi: Har bir post o‘rtacha 0 marta ko‘riladi; birinchi sutkada odatda 0 ta ko‘rish yig‘iladi.
- Reaksiyalar va o‘zaro ta’sir: Auditoriya faol: har bir postga o‘rtacha 0 ta reaksiya keladi.
- Tematik yo‘nalishlar: Kontent input, string, scanf("%d, array, element kabi asosiy mavzularga jamlangan.
📝 Tavsif va kontent siyosati
Muallif resursni shaxsiy fikrni ifoda etish maydoni sifatida ta’riflaydi:
“C Programming Codes || Quizzes || DSA
Learn along with the community
Any queries
admin - @Pradeep_saii”
Yuqori yangilanish chastotasi (oxirgi ma’lumot 12 Iyun, 2026 da olingan) sababli kanal doimo dolzarb va katta qamrovli bo‘lib qoladi. Analitika auditoriya kontent bilan faol hamkorlik qilishini, uni Texnologiyalar & Aralashmalar toifasidagi muhim ta’sir nuqtasiga aylantirishini ko‘rsatadi.
#include <stdio.h>
struct Date {
int day;
int month;
int year;
};
struct Student {
char name[50];
int rollNumber;
struct Date birthday;
};
int main() {
struct Student student1;
printf("Enter student name: ");
scanf("%s", student1.name);
printf("Enter roll number: ");
scanf("%d", &student1.rollNumber);
printf("Enter birthday (day month year): ");
scanf("%d %d %d", &student1.birthday.day, &student1.birthday.month, &student1.birthday.year);
printf("nStudent Details:n");
printf("Name: %sn", student1.name);
printf("Roll Number: %dn", student1.rollNumber);
printf("Birthday: %d/%d/%dn", student1.birthday.day, student1.birthday.month, student1.birthday.year);
return 0;
}
📤 Output:
Input: JohnDoe Input: 123 Input: 15 08 2000 Output: Enter student name: Enter roll number: Enter birthday (day month year): Student Details: Name: JohnDoe Roll Number: 123 Birthday: 15/8/2000
#include <stdio.h>
#define PI 3.14159
struct Circle {
float radius;
};
int main() {
struct Circle myCircle;
printf("Enter the radius of the circle: ");
scanf("%f", &myCircle.radius);
float area = PI * myCircle.radius * myCircle.radius;
float circumference = 2 * PI * myCircle.radius;
printf("Area of the circle: %.2fn", area);
printf("Circumference of the circle: %.2fn", circumference);
return 0;
}
📤 Output:
Input: 5 Output: Enter the radius of the circle: Area of the circle: 78.54 Circumference of the circle: 31.42
#include <stdio.h>
struct Rectangle {
float length;
float width;
};
int main() {
struct Rectangle myRectangle;
printf("Enter the length of the rectangle: ");
scanf("%f", &myRectangle.length);
printf("Enter the width of the rectangle: ");
scanf("%f", &myRectangle.width);
float area = myRectangle.length * myRectangle.width;
float perimeter = 2 * (myRectangle.length + myRectangle.width);
printf("Area of the rectangle: %.2fn", area);
printf("Perimeter of the rectangle: %.2fn", perimeter);
return 0;
}
📤 Output:
Input: 5.0 Input: 3.0 Output: Area of the rectangle: 15.00 Output: Perimeter of the rectangle: 16.00
#include <stdio.h>
#include <string.h>
struct Account {
int accountNumber;
char accountHolderName[50];
float balance;
};
int main() {
struct Account myAccount;
printf("Enter account number: ");
scanf("%d", &myAccount.accountNumber);
printf("Enter account holder name: ");
scanf(" %[^n]s", myAccount.accountHolderName);
printf("Enter initial balance: ");
scanf("%f", &myAccount.balance);
printf("nAccount Details:n");
printf("Account Number: %dn", myAccount.accountNumber);
printf("Account Holder Name: %sn", myAccount.accountHolderName);
printf("Balance: %.2fn", myAccount.balance);
float depositAmount;
printf("nEnter amount to deposit: ");
scanf("%f", &depositAmount);
myAccount.balance += depositAmount;
printf("New balance after deposit: %.2fn", myAccount.balance);
float withdrawalAmount;
printf("nEnter amount to withdraw: ");
scanf("%f", &withdrawalAmount);
if (withdrawalAmount <= myAccount.balance) {
myAccount.balance -= withdrawalAmount;
printf("New balance after withdrawal: %.2fn", myAccount.balance);
} else {
printf("Insufficient balance.n");
}
return 0;
}
📤 Output:
Input: 12345 Input: John Doe Input: 1000.00 Output: Enter account number: Enter account holder name: Enter initial balance: Account Details: Account Number: 12345 Account Holder Name: John Doe Balance: 1000.00 Enter amount to deposit: Input: 500.00 Output: New balance after deposit: 1500.00 Enter amount to withdraw: Input: 200.00 Output: New balance after withdrawal: 1300.00
#include <stdio.h>
#include <string.h>
struct Book {
char title[50];
char author[50];
int book_id;
};
int main() {
struct Book book1;
printf("Enter book title: ");
scanf(" %[^n]s", book1.title);
printf("Enter author name: ");
scanf(" %[^n]s", book1.author);
printf("Enter book ID: ");
scanf("%d", &book1.book_id);
printf("nBook Details:n");
printf("Title: %sn", book1.title);
printf("Author: %sn", book1.author);
printf("Book ID: %dn", book1.book_id);
return 0;
}
📤 Output:
Input: The Lord of the Rings Input: J.R.R. Tolkien Input: 12345 Output: Enter book title: Enter author name: Enter book ID: Book Details: Title: The Lord of the Rings Author: J.R.R. Tolkien Book ID: 12345
#include <stdio.h>
#include <stdbool.h>
typedef struct {
int day;
int month;
int year;
} Date;
bool isValidDate(Date date) {
if (date.year < 1 || date.month < 1 || date.month > 12 || date.day < 1) {
return false;
}
int daysInMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if ((date.year % 4 == 0 && date.year % 100 != 0) || (date.year % 400 == 0)) {
daysInMonth[2] = 29;
}
if (date.day > daysInMonth[date.month]) {
return false;
}
return true;
}
Date addDays(Date date, int daysToAdd) {
Date newDate = date;
int daysInMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if ((newDate.year % 4 == 0 && newDate.year % 100 != 0) || (newDate.year % 400 == 0)) {
daysInMonth[2] = 29;
}
newDate.day += daysToAdd;
while (newDate.day > daysInMonth[newDate.month]) {
newDate.day -= daysInMonth[newDate.month];
newDate.month++;
if (newDate.month > 12) {
newDate.month = 1;
newDate.year++;
if ((newDate.year % 4 == 0 && newDate.year % 100 != 0) || (newDate.year % 400 == 0)) {
daysInMonth[2] = 29;
} else {
daysInMonth[2] = 28;
}
}
}
return newDate;
}
int main() {
Date myDate;
int daysToAdd;
printf("Enter date (day month year): ");
scanf("%d %d %d", &myDate.day, &myDate.month, &myDate.year);
if (!isValidDate(myDate)) {
printf("Invalid date!n");
return 1;
}
printf("Enter number of days to add: ");
scanf("%d", &daysToAdd);
Date newDate = addDays(myDate, daysToAdd);
printf("New date: %d/%d/%dn", newDate.day, newDate.month, newDate.year);
return 0;
}
📤 Output:
Input: 28 2 2023 Output: Enter date (day month year): Enter number of days to add: 5 New date: 5/3/2023 Input: 31 12 2023 Output: Enter date (day month year): Enter number of days to add: 1 New date: 1/1/2024 Input: 29 2 2024 Output: Enter date (day month year): Enter number of days to add: 1 New date: 1/3/2024 Input: 1 1 2024 Output: Enter date (day month year): Enter number of days to add: 366 New date: 1/1/2025 Input: 31 4 2023 Output: Enter date (day month year): Invalid date!
#include <stdio.h>
struct Time {
int hours;
int minutes;
int seconds;
};
int main() {
struct Time t1, t2, sum, diff;
printf("Enter first time (hours minutes seconds): ");
scanf("%d %d %d", &t1.hours, &t1.minutes, &t1.seconds);
printf("Enter second time (hours minutes seconds): ");
scanf("%d %d %d", &t2.hours, &t2.minutes, &t2.seconds);
// Time Addition
sum.seconds = t1.seconds + t2.seconds;
sum.minutes = t1.minutes + t2.minutes + sum.seconds / 60;
sum.hours = t1.hours + t2.hours + sum.minutes / 60;
sum.minutes %= 60;
sum.seconds %= 60;
sum.hours %= 24;
printf("Sum of times: %d:%d:%dn", sum.hours, sum.minutes, sum.seconds);
// Time Subtraction (t1 - t2)
int t1_sec = t1.hours * 3600 + t1.minutes * 60 + t1.seconds;
int t2_sec = t2.hours * 3600 + t2.minutes * 60 + t2.seconds;
int diff_sec = t1_sec - t2_sec;
if (diff_sec < 0) {
diff_sec = -diff_sec; //absolute difference
}
diff.hours = diff_sec / 3600;
diff.minutes = (diff_sec % 3600) / 60;
diff.seconds = (diff_sec % 3600) % 60;
printf("Difference of times: %d:%d:%dn", diff.hours, diff.minutes, diff.seconds);
return 0;
}
📤 Output:
Input: 10 30 45 Input: 5 15 20 Output: Sum of times: 15:46:5 Output: Difference of times: 5:15:25
#include <stdio.h>
#include <math.h>
struct Point {
float x;
float y;
};
int main() {
struct Point p1, p2;
float distance;
printf("Enter x and y coordinates for point 1: ");
scanf("%f %f", &p1.x, &p1.y);
printf("Enter x and y coordinates for point 2: ");
scanf("%f %f", &p2.x, &p2.y);
distance = sqrt(pow(p2.x - p1.x, 2) + pow(p2.y - p1.y, 2));
printf("Distance between the two points: %fn", distance);
return 0;
}
📤 Output:
Input: 1.0 2.0 Input: 4.0 6.0 Output: Distance between the two points: 5.000000
#include <stdio.h>
typedef struct {
float real;
float imaginary;
} Complex;
Complex add(Complex a, Complex b) {
Complex result;
result.real = a.real + b.real;
result.imaginary = a.imaginary + b.imaginary;
return result;
}
Complex subtract(Complex a, Complex b) {
Complex result;
result.real = a.real - b.real;
result.imaginary = a.imaginary - b.imaginary;
return result;
}
int main() {
Complex num1, num2, sum, difference;
printf("Enter real and imaginary parts of first complex number: ");
scanf("%f %f", &num1.real, &num1.imaginary);
printf("Enter real and imaginary parts of second complex number: ");
scanf("%f %f", &num2.real, &num2.imaginary);
sum = add(num1, num2);
printf("Sum = %.2f + %.2fin", sum.real, sum.imaginary);
difference = subtract(num1, num2);
printf("Difference = %.2f + %.2fin", difference.real, difference.imaginary);
return 0;
}
📤 Output:
Input: 3.4 5.2 Input: -1.1 2.5 Output: Enter real and imaginary parts of first complex number: Enter real and imaginary parts of second complex number: Sum = 2.30 + 7.70i Output: Difference = 4.50 + 2.70i
#include <stdio.h>
#include <string.h>
struct Employee {
int id;
char name[50];
float salary;
};
int main() {
struct Employee emp;
printf("Enter employee ID: ");
scanf("%d", &emp.id);
printf("Enter employee name: ");
scanf(" %[^n]s", emp.name);
printf("Enter employee salary: ");
scanf("%f", &emp.salary);
printf("nEmployee Details:n");
printf("ID: %dn", emp.id);
printf("Name: %sn", emp.name);
printf("Salary: %.2fn", emp.salary);
return 0;
}
📤 Output:
Input: 123 Input: John Doe Input: 60000.50 Output: Enter employee ID: Enter employee name: Enter employee salary: Employee Details: ID: 123 Name: John Doe Salary: 60000.50
#include <stdio.h>
#include <string.h>
struct Student {
char name[50];
int rollNumber;
float marks;
};
int main() {
struct Student student1;
printf("Enter student name: ");
scanf("%s", student1.name);
printf("Enter roll number: ");
scanf("%d", &student1.rollNumber);
printf("Enter marks: ");
scanf("%f", &student1.marks);
printf("nStudent Details:n");
printf("Name: %sn", student1.name);
printf("Roll Number: %dn", student1.rollNumber);
printf("Marks: %.2fn", student1.marks);
return 0;
}
📤 Output:
Input: John Input: 123 Input: 85.5 Output: Enter student name: Enter roll number: Enter marks: Student Details: Name: John Roll Number: 123 Marks: 85.50
#include <stdio.h>
#include <stdlib.h>
struct Student {
int id;
char name[50];
float gpa;
};
int main() {
int n;
printf("Enter the number of students: ");
scanf("%d", &n);
struct Student *students[n]; // Array of structure pointers
// Allocate memory for each student and get input
for (int i = 0; i < n; i++) {
students[i] = (struct Student*)malloc(sizeof(struct Student));
printf("Enter details for student %d:n", i + 1);
printf("ID: ");
scanf("%d", &(students[i]->id));
printf("Name: ");
scanf(" %[^n]", students[i]->name); // Read name with spaces
printf("GPA: ");
scanf("%f", &(students[i]->gpa));
}
// Print the student details
printf("nStudent Details:n");
for (int i = 0; i < n; i++) {
printf("Student %d:n", i + 1);
printf("ID: %dn", students[i]->id);
printf("Name: %sn", students[i]->name);
printf("GPA: %.2fn", students[i]->gpa);
}
// Free the allocated memory
for (int i = 0; i < n; i++) {
free(students[i]);
}
return 0;
}
📤 Output:
Input: 2 Input: 123 Input: Alice Smith Input: 3.85 Input: 456 Input: Bob Johnson Input: 3.5 Output: Enter the number of students: Enter details for student 1: ID: Name: GPA: Enter details for student 2: ID: Name: GPA: Student Details: Student 1: ID: 123 Name: Alice Smith GPA: 3.85 Student 2: ID: 456 Name: Bob Johnson GPA: 3.50
#include <stdio.h>
#include <stdlib.h>
struct Person {
char name[50];
int age;
};
int main() {
struct Person person1;
struct Person *ptrPerson;
ptrPerson = &person1;
printf("Enter name: ");
scanf("%s", ptrPerson->name);
printf("Enter age: ");
scanf("%d", &ptrPerson->age);
printf("Name: %sn", ptrPerson->name);
printf("Age: %dn", ptrPerson->age);
return 0;
}
📤 Output:
Input: John Input: 30 Output: Enter name: Enter age: Name: John Age: 30
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr;
ptr = (int *)malloc(sizeof(int));
if (ptr == NULL) {
printf("Memory allocation failed!n");
return 1;
}
printf("Enter an integer value: ");
scanf("%d", ptr);
printf("You entered: %dn", *ptr);
free(ptr);
ptr = NULL;
return 0;
}
📤 Output:
Input: 10 Output: Enter an integer value: You entered: 10
#include <stdio.h>
#include <stdlib.h>
int main() {
int *arr;
int size, new_size, i;
printf("Enter the initial size of the array: ");
scanf("%d", &size);
arr = (int *)malloc(size * sizeof(int));
if (arr == NULL) {
printf("Memory allocation failed.n");
return 1;
}
printf("Enter %d elements:n", size);
for (i = 0; i < size; i++) {
scanf("%d", &arr[i]);
}
printf("Enter the new size of the array: ");
scanf("%d", &new_size);
arr = (int *)realloc(arr, new_size * sizeof(int));
if (arr == NULL) {
printf("Memory reallocation failed.n");
return 1;
}
printf("Memory reallocated successfully.n");
if (new_size > size) {
printf("Enter the remaining %d elements:n", new_size - size);
for (i = size; i < new_size; i++) {
scanf("%d", &arr[i]);
}
}
printf("Elements of the array:n");
for (i = 0; i < new_size; i++) {
printf("%d ", arr[i]);
}
printf("n");
free(arr);
return 0;
}
📤 Output:
Input: 3 Output: Enter the initial size of the array: Input: 1 Output: Enter 3 elements: Input: 2 Output: Input: 3 Output: Enter the new size of the array: Input: 5 Output: Memory reallocated successfully. Output: Enter the remaining 2 elements: Input: 4 Output: Input: 5 Output: Elements of the array: Output: 1 2 3 4 5
#include <stdio.h>
#include <stdlib.h>
int main() {
int *arr_malloc, *arr_calloc;
int n, i;
printf("Enter the number of elements: ");
scanf("%d", &n);
arr_malloc = (int*) malloc(n * sizeof(int));
if (arr_malloc == NULL) {
printf("Memory allocation failed using malloc!n");
return 1;
}
printf("Memory allocated successfully using malloc.n");
printf("Enter elements for malloc array:n");
for (i = 0; i < n; i++) {
scanf("%d", &arr_malloc[i]);
}
printf("Elements in malloc array:n");
for (i = 0; i < n; i++) {
printf("%d ", arr_malloc[i]);
}
printf("n");
arr_calloc = (int*) calloc(n, sizeof(int));
if (arr_calloc == NULL) {
printf("Memory allocation failed using calloc!n");
free(arr_malloc);
return 1;
}
printf("Memory allocated successfully using calloc. Initialized to 0.n");
printf("Enter elements for calloc array:n");
for (i = 0; i < n; i++) {
scanf("%d", &arr_calloc[i]);
}
printf("Elements in calloc array:n");
for (i = 0; i < n; i++) {
printf("%d ", arr_calloc[i]);
}
printf("n");
free(arr_malloc);
free(arr_calloc);
return 0;
}
📤 Output:
Input: 3 Output: Enter the number of elements: Memory allocated successfully using malloc. Enter elements for malloc array: Input: 10 Input: 20 Input: 30 Output: Elements in malloc array: 10 20 30 Output: Memory allocated successfully using calloc. Initialized to 0. Enter elements for calloc array: Input: 40 Input: 50 Input: 60 Output: Elements in calloc array: 40 50 60
#include <stdio.h>
int add(int a, int b) {
return a + b;
}
int subtract(int a, int b) {
return a - b;
}
int main() {
int x, y, choice, result;
int (*operation)(int, int);
printf("Enter two numbers: ");
scanf("%d %d", &x, &y);
printf("Choose an operation:n");
printf("1. Addn");
printf("2. Subtractn");
printf("Enter your choice (1 or 2): ");
scanf("%d", &choice);
if (choice == 1) {
operation = add;
} else if (choice == 2) {
operation = subtract;
} else {
printf("Invalid choice.n");
return 1;
}
result = operation(x, y);
printf("Result: %dn", result);
return 0;
}
📤 Output:
Input: 5 3 Input: 1 Output: Enter two numbers: Choose an operation: 1. Add 2. Subtract Enter your choice (1 or 2): Result: 8 Input: 10 4 Input: 2 Output: Enter two numbers: Choose an operation: 1. Add 2. Subtract Enter your choice (1 or 2): Result: 6 Input: 2 7 Input: 3 Output: Enter two numbers: Choose an operation: 1. Add 2. Subtract Enter your choice (1 or 2): Invalid choice.
#include <stdio.h>
int add(int a, int b) {
return a + b;
}
int subtract(int a, int b) {
return a - b;
}
int main() {
int x, y, choice, result;
int (*operation)(int, int);
printf("Enter two integers: ");
scanf("%d %d", &x, &y);
printf("Choose an operation:n");
printf("1. Addn");
printf("2. Subtractn");
printf("Enter your choice (1 or 2): ");
scanf("%d", &choice);
if (choice == 1) {
operation = add;
} else if (choice == 2) {
operation = subtract;
} else {
printf("Invalid choice.n");
return 1; // Indicate an error
}
result = operation(x, y);
printf("Result: %dn", result);
return 0;
}
📤 Output:
Input: 5 3 Input: 1 Output: Enter two integers: Choose an operation: 1. Add 2. Subtract Enter your choice (1 or 2): Result: 8 Input: 10 4 Input: 2 Output: Enter two integers: Choose an operation: 1. Add 2. Subtract Enter your choice (1 or 2): Result: 6 Input: 2 7 Input: 3 Output: Enter two integers: Choose an operation: 1. Add 2. Subtract Enter your choice (1 or 2): Invalid choice.
#include <stdio.h>
int main() {
int num = 10;
int *ptr = #
int **ptr_to_ptr = &ptr;
printf("Value of num: %dn", num);
printf("Address of num: %pn", (void*)&num);
printf("Value of ptr: %pn", (void*)ptr);
printf("Address of ptr: %pn", (void*)&ptr);
printf("Value pointed to by ptr: %dn", *ptr);
printf("Value of ptr_to_ptr: %pn", (void*)ptr_to_ptr);
printf("Address of ptr_to_ptr: %pn", (void*)&ptr_to_ptr);
printf("Value pointed to by ptr_to_ptr: %pn", (void*)*ptr_to_ptr);
printf("Value pointed to by *ptr_to_ptr: %dn", **ptr_to_ptr);
return 0;
}
📤 Output:
Value of num: 10 Address of num: 0x7ffc75467b18 Value of ptr: 0x7ffc75467b18 Address of ptr: 0x7ffc75467b20 Value pointed to by ptr: 10 Value of ptr_to_ptr: 0x7ffc75467b20 Address of ptr_to_ptr: 0x7ffc75467b28 Value pointed to by ptr_to_ptr: 0x7ffc75467b18 Value pointed to by *ptr_to_ptr: 10
Endi mavjud! Telegram Tadqiqoti 2025 — yilning asosiy insaytlari 
