# c

## C/C++ Program to remove all zeros from a number

Write a program to remove all zeros from a integer number in C/C++. For example, Input 809210003 Output 89213 Steps Take input from the user. Let it be N. Set num = 0. num will store the output. Repeat the following steps while N > 0 Set R = N % 10. This step stores …

## C Program to Calculate Simple Interest and Compound Interest

In this article, we will write a program to calculate simple interest and compound interest. The formula for simple interest and compound interest is given below: First the program will ask the user to enter principal amount, time period and rate of interest. Then we will use the above formulas to calculate S.I and C.I.

## C Program to count the number of vowels in a text file

Write a program to count the number of vowels in a text file in C. Steps Ask the user to enter a file name. Initialize a variable count = 0 to store the vowel count. Read the content of the file character by character. Use a switch statement to check if a character is a vowel or …

## C/C++ Program to find the sum of all elements of a matrix

Write a program in C to find the sum of all elements of a matrix. For exampe, Input { {1, 2, 4} {1, 3, 0} {2, 3, 5} } Output 21 Explaination 1 + 2 + 4 + 1 + 3 + 0 + 2 + 3 + 5 = 21 This problem is very …

## C Program to Count Unique Digits in a Number

Write a program to count number of unique digits in a given number in C/C++. For example, Input 12334 Output 3 Explaination Unique Digits in 12334 = { 1, 2, 4 } Input 98000 Output 2 Explaination Unique Digits in 12334 = { 9, 8 } Logic First, we read each digit of the given …

## C/C++ Program to Count Even Digits in a Given Number

Write a program to count the number of even digits in a given number in C/C++. For example, Input 1225678 Output 4 Approach To solve this problem, we will read each digit of the input number one-by-one using the Modulus and Division operator and check if the digit is even or not. Steps Take input …

## C Program to Count Number of Blank Spaces in a File

Write a program to count the number of blacks spaces in a file in C. For example, Content of Input File My name is John Smith I am 14 years old I Likes to play video games Output Number of blank spaces = 13 Steps Ask the user to enter a file name. Initialize a …

## C Program to Count the Number of Trailing Zeros in a Binary Number

In this article, we will discuss different ways to count the number of trailing in a given integer in its binary form. What are Trailing Zeros? Trailing zeros are a sequence of zeros starting from the least significant place in a number, after which no other digit follows. For example, the number of trailing zeros …

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

Write a program to find the sum of cube of digits of a number. For example, Input 12345 Output 225 Explaination 13 + 23 + 33 + 43 + 53 = 225 Approach The solution to this problem is very simple. We will simply using % ( MOD operator ) to read each digit of …

## C Program to Print the Rightmost Digit of a Given Number

Write a program to print the rightmost ( last ) digit of a given number in C. For example, Input 821309 Output 9 The problem is very simple. The right-most digit of a number is basically the remainder of that number with 10. We can use the ‘%’ operator to get the remainder. Output Now, …