# c

## C/C++ Program to Find the Sum of Even Digits in a Number

Write a program to find the sum of even digits in a given integer number in C/C++. Example, Input 5234123 Output 8 Explaination There are 4 even digits in the input number – { 2, 4, 2 } 2 + 4 + 2 = 8 We will discuss 2 techniques to solve this question. Method …

## C/C++ Program to Find the Sum of Odd Digits in a Given Number

Write a program to find the sum of odd digits in a given integer number in C/C++. Example, Input 1234253 Output 12 Explaination There are 4 odd digits in the input number – { 1, 3, 5, 3} 1 + 3 + 5 + 3 = 12 We will discuss 2 techniques to solve this …

## C/C++ Program to count the number of articles in a string

Write a program to count the number of articles in a string in C/C++. Example, Input An apple a day keeps the doctor away Output Number of “a” = 1 Number of “an” = 1 Number of “the” = 1 There are 3 articles in the English language – “a”, “an” and “the”. The problem …

## C/C++ Program to count the number of vowels and consonants in a string using pointers

Write a program in C/C++ to count the number of vowels and consonants in a string using pointers. Example, Input MyNameIsJohnSmith Output Consonants: 12 Vowels: 5 Steps Let str[] be the input string. Initialize c1 = 0 and c2 = 0. c1 stores the number of consonants and c2 stores the number of vowels. Read …

## C Program to count the number of unique characters in a string

Write a program to count the number of distinct characters in a string in C/C++. Example, Input Willingly Output 6 Before we move further, we should know that there is a total of 128 characters in C/C++. Each character is represented by a unique integer value in the range [0, 127]. This numeric value is …

## C Program to swap the first and last character of a string

Write a program to swap the first and last character of a string in C. Example, Input: HelloWorld Output: delloWorlH Let str[] be the input string of size n. The first character of str[] is given by str. The last character of str[] is given by str[n-1]. We can find the value of n using …

## C/C++ Program to print multiples of 15 from m to n

Write a program to print multiples of 15 in a given range ( from m to n ) in C/C++. Example, Input m: 10 n: 100 Output 15 30 45 60 75 90 Method 1: Brute Force The simplest way to print multiples of 15 is to iterate each element from m to n and …

## C/C++ Program to print alphabets in reverse order

Write a program to print alphabets in reverse order in C/C++. The logic to print alphabets in reverse order is the same as printing alphabets in serial order. We print alphabets based on the fact that the ASCII value of all English alphabets is contiguous. The only difference is instead of iterating from ‘A’ to …

## C/C++ Program to find bitwise OR of two decimal numbers

In this post, we will learn how to find bitwise OR of two decimal numbers in C/C++. The simplest way to find bitwise OR of two decimal numbers is to use bitwise OR ( | ) operator. Syntax of bitwise OR operator The binary OR of a and b is in c. Output Bitwise OR …

## C/C++ Program to display the middle row and column of Matrix

Write a program to display the middle rows and columns of a matrix in c/c++. Example, Input 1 2 1 2 1 2 3 2 3 2 4 5 5 5 4 0 0 0 0 0 9 9 9 9 9 Output Middle row: 4 5 5 5 4 Middle Column: 1 2 5 …