Category: C program

python tutorials and learn python

Created with Sketch.

C Program to Sort Elements in Lexicographical Order (Dictionary Order)

C Program to Sort Elements in Lexicographical Order (Dictionary Order) This program sorts the 5 strings entered by the user in the lexicographical order (dictionary order). This program takes 5 words (strings) from the user and sorts them in lexicographical order. Example: Sort strings in the dictionary order #include <stdio.h> #include <string.h> int main() {…
Read more

C Program to Copy String Without Using strcpy()

C Program to Copy String Without Using strcpy() In this article, you’ll learn to copy string without using the library function strcpy(). You can use the strcpy() function to copy the content of one string to another but, this program copies the content of one string to another manually without using strcpy() function. Example: Copy…
Read more

C Program to Concatenate Two Strings

C Program to Concatenate Two Strings In this article, you’ll learn to easily concatenate two strings without using standard library function strcat(). You can concatenate two strings easily using standard library function strcat() but, this program concatenates two strings manually without using strcat() function. Example: Concatenate Two Strings Without Using strcat() #include <stdio.h> int main()…
Read more

C Program to Find the Length of a String

C Program to Find the Length of a String In this article, you’ll learn to find the length of a string without using strlen() function. You can use standard library function strlen() to find the length of a string but, this program computes the length of a string manually without using strlen() funtion. Example: Calculate…
Read more

C Program to Remove all Characters in a String Except Alphabets

C Program to Remove all Characters in a String Except Alphabets This program takes a strings from user and removes all characters in that string except alphabets. Example: Remove Characters in String Except Alphabets #include<stdio.h> int main() { char line[150]; int i, j; printf(“Enter a string: “); gets(line); for(i = 0; line[i] != ‘\0’; ++i)…
Read more

C Program to Count the Number of Vowels, Consonants and so on

C Program to Count the Number of Vowels, Consonants and so on This program counts the number of vowels, consonants, digits and white-spaces in a string which is entered by the user. Example: Program to count vowels, consonants etc. #include <stdio.h> int main() { char line[150]; int i, vowels, consonants, digits, spaces; vowels = consonants…
Read more

C Program to Find the Frequency of Characters in a String

C Program to Find the Frequency of Characters in a String This program asks user to enter a string and a character and checks how many times the character is repeated in the string. Example: Find the Frequency of Characters #include <stdio.h> int main() { char str[1000], ch; int i, frequency = 0; printf(“Enter a…
Read more

C Program to Find Largest Number Using Dynamic Memory Allocation

C Program to Find Largest Number Using Dynamic Memory Allocation In this program, you’ll learn to use calloc() function to allocate the memory dynamically to find the largest element. Depending upon the number of elements, the required size is allocated which prevents the wastage of memory. ┬áIf no memory is allocated, error is displayed and…
Read more

C Program Swap Numbers in Cyclic Order Using Call by Reference

C Program Swap Numbers in Cyclic Order Using Call by Reference This program takes three integers from the user and swaps them in cyclic order using pointers. Three variables entered by the user are stored in variables a, b and c respectively. Then, these variables are passed to the function cyclicSwap(). Instead of passing the…
Read more

C Program to Access Array Elements Using Pointer

C Program to Access Array Elements Using Pointer This program declares an array of five elements, and the elements of the array are accessed using a pointer. Example: Access Array Elements Using Pointers #include <stdio.h> int main() { int data[5], i; printf(“Enter elements: “); for(i = 0; i < 5; ++i) scanf(“%d”, data + i);…
Read more