Posts

Showing posts from April, 2026

C program to count Vowels, Consonants and digits in a String

              String is a collection of characters. This program counts the vowels present in the input string, consonants appear in the input and numbers available in the string. Let us implement it in C language .               This program reads the input string from the user using fgets() function . Using a for loop , each character is separated. Each character is checked whether it is an alphabet or a digit . If it is a digit, the count of digit variable is increased by one. If it is an alphabet, the alphabet is converted as lowercase. It is compared with vowels. If it a vowel, vowel count is increased. Otherwise, consonant count is increased. Finally, each count is displayed. C Code: #include <stdio.h> #include <ctype.h>   //It has built-in function to check the characters and numbers int main() {     char s[100]; ...

Reverse a string in C

               Reverse a string deal with reverse each character of the entire string. It can be done by user defined function or built-in function. First, we implement it using the user defined function. It uses reverse_String() for implementing the function. 👉C Code: //include the header files #include <stdio.h> #include <string.h> //a user defined function ‘reverse_String()’ is defined here. //starting and ending point and temporary variables are created. //each character is read and reversed using temp variable. void reverse_String(char s[]) {     int start = 0;     int end = strlen(s) - 1;     char temp;     while (start < end) {         // Exchange the characters         temp = s[start];         s[start] = s[end];   ...