uz
Feedback
C Programming Codes

C Programming Codes

Kanalga Telegram’da o‘tish

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.

13 431
Obunachilar
-924 soatlar
-577 kunlar
-23930 kunlar
Postlar arxiv
💻 Array of Pointers
#include <stdio.h>
#include <stdlib.h>

int main() {
    int num1 = 10, num2 = 20, num3 = 30;

    // Array of pointers to integers
    int *ptr_array[3];

    // Assigning addresses of integers to the pointer array
    ptr_array[0] = &num1;
    ptr_array[1] = &num2;
    ptr_array[2] = &num3;

    // Accessing values using the array of pointers
    printf("Value at ptr_array[0]: %dn", *ptr_array[0]);
    printf("Value at ptr_array[1]: %dn", *ptr_array[1]);
    printf("Value at ptr_array[2]: %dn", *ptr_array[2]);

    return 0;
}
📤 Output:
Value at ptr_array[0]: 10
Value at ptr_array[1]: 20
Value at ptr_array[2]: 30

💻 Pointer Arithmetic Operations
#include <stdio.h>

int main() {
    int arr[] = {10, 20, 30, 40, 50};
    int *ptr = arr;

    printf("Value of arr[0]: %dn", *ptr);

    ptr++; // Increment pointer to point to the next element

    printf("Value of arr[1]: %dn", *ptr);

    printf("Address of arr[1]: %pn", (void*)ptr);

    printf("Value of arr[2]: %dn", *(ptr + 1)); // Accessing arr[2] using pointer arithmetic

    ptr = arr + 3; // Pointing to arr[3]

    printf("Value of arr[3]: %dn", *ptr);

    ptr--; // Decrement pointer

    printf("Value of arr[2]: %dn", *ptr);

    int diff = ptr - arr; // Calculating the difference between pointers

    printf("Difference between pointers: %dn", diff);

    return 0;
}
📤 Output:
Value of arr[0]: 10
Value of arr[1]: 20
Address of arr[1]: 0x7ffc752b1004
Value of arr[2]: 30
Value of arr[3]: 40
Value of arr[2]: 30
Difference between pointers: 2

💻 Compare Strings Using Pointers
#include <stdio.h>
#include <string.h>

int main() {
    char str1[100], str2[100];
    char *ptr1, *ptr2;
    int result = 0;

    printf("Enter the first string: ");
    scanf("%s", str1);

    printf("Enter the second string: ");
    scanf("%s", str2);

    ptr1 = str1;
    ptr2 = str2;

    while (*ptr1 != '0' && *ptr2 != '0') {
        if (*ptr1 != *ptr2) {
            result = (*ptr1 > *ptr2) ? 1 : -1;
            break;
        }
        ptr1++;
        ptr2++;
    }

    if (result == 0 && (*ptr1 == '0' && *ptr2 != '0'))
        result = -1;
    else if (result == 0 && (*ptr1 != '0' && *ptr2 == '0'))
        result = 1;

    if (result == 0) {
        printf("Strings are equal.n");
    } else if (result > 0) {
        printf("String 1 is greater than String 2.n");
    } else {
        printf("String 1 is less than String 2.n");
    }

    return 0;
}
📤 Output:
Input: apple
Input: banana
Output: String 1 is less than String 2.

Input: banana
Input: apple
Output: String 1 is greater than String 2.

Input: apple
Input: apple
Output: Strings are equal.

Input: apple
Input: app
Output: String 1 is greater than String 2.

Input: app
Input: apple
Output: String 1 is less than String 2.

Input: A
Input: a
Output: String 1 is less than String 2.

Input: abc
Input: abd
Output: String 1 is less than String 2.

💻 Concatenate Strings Using Pointers
#include <stdio.h>
#include <string.h>

int main() {
  char str1[100], str2[100];

  printf("Enter the first string: ");
  scanf("%s", str1);

  printf("Enter the second string: ");
  scanf("%s", str2);

  char *ptr1 = str1;
  char *ptr2 = str2;

  // Move pointer to the end of the first string
  while (*ptr1 != '0') {
    ptr1++;
  }

  // Concatenate the second string to the first
  while (*ptr2 != '0') {
    *ptr1 = *ptr2;
    ptr1++;
    ptr2++;
  }

  *ptr1 = '0'; // Null-terminate the concatenated string

  printf("Concatenated string: %sn", str1);

  return 0;
}
📤 Output:
Input: Hello
Input: World
Output: Concatenated string: HelloWorld

💻 Find Length of String Using Pointers
#include <stdio.h>

int main() {
    char str[100];
    char *ptr;
    int length = 0;

    printf("Enter a string: ");
    scanf("%s", str);

    ptr = str;

    while (*ptr != '0') {
        length++;
        ptr++;
    }

    printf("Length of the string: %dn", length);

    return 0;
}
📤 Output:
Input: Hello
Output: Length of the string: 5

Input: C programming
Output: Length of the string: 1

Input: This is a test
Output: Length of the string: 4

💻 Sort Array Using Pointers
#include <stdio.h>

void sortArray(int *arr, int size) {
    int i, j, temp;
    for (i = 0; i < size - 1; i++) {
        for (j = 0; j < size - i - 1; j++) {
            if (*(arr + j) > *(arr + j + 1)) {
                temp = *(arr + j);
                *(arr + j) = *(arr + j + 1);
                *(arr + j + 1) = temp;
            }
        }
    }
}

int main() {
    int size, i;

    printf("Enter the size of the array: ");
    scanf("%d", &size);

    int arr[size];

    printf("Enter the elements of the array:n");
    for (i = 0; i < size; i++) {
        scanf("%d", (arr + i));
    }

    sortArray(arr, size);

    printf("Sorted array:n");
    for (i = 0; i < size; i++) {
        printf("%d ", *(arr + i));
    }
    printf("n");

    return 0;
}
📤 Output:
Input: 5
Input: 5
Input: 4
Input: 3
Input: 2
Input: 1
Output: Enter the size of the array: Enter the elements of the array:
Sorted array:
1 2 3 4 5

💻 Reverse Array Using Pointers
#include <stdio.h>

int main() {
    int n;

    printf("Enter the size of the array: ");
    scanf("%d", &n);

    int arr[n];

    printf("Enter the elements of the array:n");
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    int *start = arr;
    int *end = arr + n - 1;
    int temp;

    while (start < end) {
        temp = *start;
        *start = *end;
        *end = temp;
        start++;
        end--;
    }

    printf("Reversed array:n");
    for (int i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    printf("n");

    return 0;
}
📤 Output:
Input: 5
Input: 1
Input: 2
Input: 3
Input: 4
Input: 5
Output: Enter the size of the array: Enter the elements of the array:
Reversed array:
5 4 3 2 1

💻 Copy Array Using Pointers
#include <stdio.h>

int main() {
    int n;

    printf("Enter the size of the array: ");
    scanf("%d", &n);

    int source[n];
    int destination[n];
    int *sourcePtr = source;
    int *destinationPtr = destination;

    printf("Enter elements of the source array:n");
    for (int i = 0; i < n; i++) {
        scanf("%d", sourcePtr + i);
    }

    for (int i = 0; i < n; i++) {
        *(destinationPtr + i) = *(sourcePtr + i);
    }

    printf("Elements of the destination array:n");
    for (int i = 0; i < n; i++) {
        printf("%d ", *(destinationPtr + i));
    }
    printf("n");

    return 0;
}
📤 Output:
Input: 5
Input: 1
Input: 2
Input: 3
Input: 4
Input: 5
Output: Enter the size of the array: Enter elements of the source array:
Elements of the destination array:
1 2 3 4 5

💻 Access Array Elements Using Pointers
#include <stdio.h>

int main() {
    int arr[5] = {10, 20, 30, 40, 50};
    int *ptr = arr; // Pointer to the first element of the array

    printf("Accessing array elements using pointers:n");

    for (int i = 0; i < 5; i++) {
        printf("Element %d: %dn", i, *(ptr + i)); // Accessing element at index i using pointer arithmetic
    }

    printf("nAccessing array elements using pointer increment:n");

    ptr = arr; // Reset the pointer to the beginning of the array
    for (int i = 0; i < 5; i++) {
        printf("Element %d: %dn", i, *ptr);
        ptr++; // Increment the pointer to point to the next element
    }

    return 0;
}
📤 Output:
Accessing array elements using pointers:
Element 0: 10
Element 1: 20
Element 2: 30
Element 3: 40
Element 4: 50

Accessing array elements using pointer increment:
Element 0: 10
Element 1: 20
Element 2: 30
Element 3: 40
Element 4: 50

💻 Swap Two Numbers Using Pointers
#include <stdio.h>

void swap(int *x, int *y) {
  int temp = *x;
  *x = *y;
  *y = temp;
}

int main() {
  int a, b;

  printf("Enter two numbers: ");
  scanf("%d %d", &a, &b);

  printf("Before swap: a = %d, b = %dn", a, b);

  swap(&a, &b);

  printf("After swap: a = %d, b = %dn", a, b);

  return 0;
}
📤 Output:
Input: 5 10
Output: Enter two numbers: Before swap: a = 5, b = 10
After swap: a = 10, b = 5

🔧 Pointers

💻 Toggle Case of Each Character
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char str[100];
    int i;

    printf("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    for (i = 0; str[i] != '0'; i++) {
        if (islower(str[i])) {
            str[i] = toupper(str[i]);
        } else if (isupper(str[i])) {
            str[i] = tolower(str[i]);
        }
    }

    printf("Toggled string: %s", str);

    return 0;
}
📤 Output:
Input: Hello World!
Output: Enter a string: Toggled string: hELLO wORLD!
Input: MiXeD CaSe
Output: Enter a string: Toggled string: mIxEd cAsE
Input: 123 abc ABC
Output: Enter a string: Toggled string: 123 abc abc
Input: Test_String
Output: Enter a string: Toggled string: tEST_sTRING
Input: a
Output: Enter a string: Toggled string: A
Input: A
Output: Enter a string: Toggled string: a
Input: This is a test string.
Output: Enter a string: Toggled string: tHIS IS A TEST STRING.
Input:
Output: Enter a string: Toggled string:

💻 Capitalize First Letter of Each Word
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char str[100];
    int i;

    printf("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    str[strcspn(str, "n")] = 0;

    if (strlen(str) > 0) {
        str[0] = toupper(str[0]);
    }

    for (i = 1; str[i] != '0'; i++) {
        if (str[i - 1] == ' ') {
            str[i] = toupper(str[i]);
        }
    }

    printf("Capitalized string: %sn", str);

    return 0;
}
📤 Output:
Input: hello world
Output: Capitalized string: Hello World

Input: this is a test
Output: Capitalized string: This Is A Test

Input: a very long string to test
Output: Capitalized string: A Very Long String To Test

Input: 123 abc
Output: Capitalized string: 123 Abc

Input:
Output: Capitalized string:

💻 Check if String Contains Only Alphabet
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char str[100];
    int i, flag = 1;

    printf("Enter a string: ");
    scanf("%s", str);

    for (i = 0; str[i] != '0'; i++) {
        if (!isalpha(str[i])) {
            flag = 0;
            break;
        }
    }

    if (flag == 1) {
        printf("The string contains only alphabets.n");
    } else {
        printf("The string does not contain only alphabets.n");
    }

    return 0;
}
📤 Output:
Input: HelloWorld
Output: The string contains only alphabets.

Input: Hello123World
Output: The string does not contain only alphabets.

Input: AbCdEfGhIjKlMnOpQrStUvWxYz
Output: The string contains only alphabets.

Input: abcdefghijklmnopqrstuvwxyz
Output: The string contains only alphabets.

Input: 12345
Output: The string does not contain only alphabets.

Input: !@#$%^
Output: The string does not contain only alphabets.

Input: Hello World
Output: The string contains only alphabets.

💻 Check if String Contains Only Digits
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char str[100];
    int i, is_digit_only = 1;

    printf("Enter a string: ");
    scanf("%s", str);

    for (i = 0; str[i] != '0'; i++) {
        if (!isdigit(str[i])) {
            is_digit_only = 0;
            break;
        }
    }

    if (is_digit_only) {
        printf("The string contains only digits.n");
    } else {
        printf("The string does not contain only digits.n");
    }

    return 0;
}
📤 Output:
Input: 12345
Output: The string contains only digits.

Input: abc123
Output: The string does not contain only digits.

Input: 9876
Output: The string contains only digits.

Input: 12.34
Output: The string does not contain only digits.

Input:
Output: The string contains only digits.

💻 Replace Character in String
// Code not available
📤 Output:
Because the code is not available, I cannot provide the output.

💻 Find Last Occurrence of Character
#include <stdio.h>
#include <string.h>

int main() {
    char str[100];
    char ch;
    int i, last_occurrence = -1;

    printf("Enter a string: ");
    scanf("%s", str);

    printf("Enter the character to find: ");
    scanf(" %c", &ch);

    for (i = 0; str[i] != '0'; i++) {
        if (str[i] == ch) {
            last_occurrence = i;
        }
    }

    if (last_occurrence != -1) {
        printf("Last occurrence of '%c' found at index: %dn", ch, last_occurrence);
    } else {
        printf("'%c' not found in the string.n", ch);
    }

    return 0;
}
📤 Output:
Input: hello
Input: l
Output: Last occurrence of 'l' found at index: 3

Input: banana
Input: a
Output: Last occurrence of 'a' found at index: 5

Input: world
Input: z
Output: 'z' not found in the string.

Input: programming
Input: g
Output: Last occurrence of 'g' found at index: 8

💻 Find First Occurrence of Character
#include <stdio.h>
#include <string.h>

int main() {
    char str[100];
    char ch;
    int i;
    int index = -1;

    printf("Enter a string: ");
    scanf("%s", str);

    printf("Enter the character to find: ");
    scanf(" %c", &ch);

    for (i = 0; str[i] != '0'; i++) {
        if (str[i] == ch) {
            index = i;
            break;
        }
    }

    if (index != -1) {
        printf("First occurrence of '%c' found at index: %dn", ch, index);
    } else {
        printf("'%c' not found in the string.n", ch);
    }

    return 0;
}
📤 Output:
Input: hello
Input: l
Output: First occurrence of 'l' found at index: 2

Input: world
Input: z
Output: 'z' not found in the string.

Input: banana
Input: a
Output: First occurrence of 'a' found at index: 1

Input: test string
Input: t
Output: First occurrence of 't' found at index: 0

Input: test string
Input:
Output: '
' not found in the string.

💻 Remove All Whitespaces from String
#include <stdio.h>
#include <string.h>

int main() {
  char str[100];
  int i, j = 0;

  printf("Enter a string: ");
  fgets(str, sizeof(str), stdin);

  str[strcspn(str, "n")] = 0;

  for (i = 0; str[i] != '0'; i++) {
    if (str[i] != ' ') {
      str[j] = str[i];
      j++;
    }
  }
  str[j] = '0';

  printf("String after removing whitespaces: %sn", str);

  return 0;
}
📤 Output:
Input: Hello World
Output: String after removing whitespaces: HelloWorld

Input: This is a test
Output: String after removing whitespaces: Thisisatest

Input:   Leading and trailing spaces
Output: String after removing whitespaces: Leadingandtrailingspaces

Input: No spaces
Output: String after removing whitespaces: Nospaces

Input:
Output: String after removing whitespaces:

💻 Check if Two Strings are Anagrams
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char str1[100], str2[100];
    int freq1[26] = {0}, freq2[26] = {0};
    int i;

    printf("Enter first string: ");
    scanf("%s", str1);

    printf("Enter second string: ");
    scanf("%s", str2);

    if (strlen(str1) != strlen(str2)) {
        printf("Strings are not anagrams.n");
        return 0;
    }

    for (i = 0; str1[i] != '0'; i++) {
        str1[i] = tolower(str1[i]);
        freq1[str1[i] - 'a']++;
    }

    for (i = 0; str2[i] != '0'; i++) {
        str2[i] = tolower(str2[i]);
        freq2[str2[i] - 'a']++;
    }

    for (i = 0; i < 26; i++) {
        if (freq1[i] != freq2[i]) {
            printf("Strings are not anagrams.n");
            return 0;
        }
    }

    printf("Strings are anagrams.n");

    return 0;
}
📤 Output:
Input: listen
Input: silent
Output: Strings are anagrams.

Input: hello
Input: world
Output: Strings are not anagrams.

Input: RaceCar
Input: carraceR
Output: Strings are anagrams.

Input: abc
Input: abcd
Output: Strings are not anagrams.

C Programming Codes - Telegram kanali @c_programming_codes statistikasi va tahlili