## Sum of Digits of a Number in C++

Below I have shared a C++ program to find the sum of the digits of a number. For example, given number is 238 then the sum of digits will be 13. I am using very simple logic. If we find the mod of any number by 10 then the result is the last digit of …

## C++ Program to Find Sum of First n Natural Numbers

Here I have given C++ program to find the sum of the first n natural numbers. First of all, I am reading the value of n and then calculating the sum using for loop. If you have any doubts related to the program then feel free to ask in the comment section. C++ Program to …

## C++ Program to Check Character is Uppercase, Lowercase, Digit, or Special Character

Below I have shared a C++ program to check whether a given character is an uppercase or lowercase alphabet, a digit, or a special character. First of all, I read a character and then compare it with the ASCII values given below. If the ASCII value of the character is other than the values mentioned …

## C++ Program to Find Square Root of a Number

Square root in C++ can be calculated using sqrt() function defined in math.h header file. This function takes a number as an argument and returns the square root of that number. Below I have shared a program to find square root in C++. If you have any problem then you can freely ask it by …

## C++ Program to Find Factorial of a Number

Here I have shared the factorial program in C++. A Factorial is the product of a number and all the numbers below it. For example, the factorial of 4! = 4 × 3 × 2 × 1 = 24. Output: Enter number: 5Factorial of 5 is: 120 If you have any problem regarding the below …

## C++ Program to Convert Days Into Years, Weeks and Days

Below I have shared the C++ program to convert given number of days into years, weeks and days.   For example if user has entered 365 days (not a leap year) then the output will be:   Years: 1 Weeks: 0 Days: 0     If you have any problem regarding above years, weeks and …