- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7347 Articles for C++
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
750 Views
Counting the number of trailing zeroes in a factorial number is done by counting the number of 2s and 5s in the factors of the number. Because 2*5 gives 10 which is a trailing 0 in the factorial of a number.ExampleFactorial of 7 = 5040, the number of trailing 0’s is 1.Based on our logic 7! = 2*3*4*5*6*7, it has 3 2s and 1 5s so the number of trailing 0’s is 1.#include using namespace std; int main() { int n = 45; int count = 0; for (int i = 5; n / i >= 1; i *= 5) count += n / i; cout
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
84 Views
Smallest K digit number that divisible by X is found using the formula by checking divisible by X. The formula works in the following way −Compute minimum K digit number [min] for example: 10/100/1000 etc.Now find if min is divisible by X. if yes, then this is the answer.If not, then min+X - ([min+X]%k) is the answer.Example#include #include using namespace std; int main() { int X = 83; int K = 5; cout
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
1K+ Views
Finding the number of vowels in a string using pointers need you to understand string, vowels and how to use pointer with string.String is an array of characters. And vowels are characters from the set {a, e, i, o, u}. Pointer is a variable that stores the value of memory location on a variable.To find the number of vowels in a string. We will traverse the string and then compare each character with vowels and if it is equal then it increase a counter otherwise not.Condition of the below code is that it requires a string that has all lowercase ... Read More
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
197 Views
This program is used to find all the even factors and calculate the sum of these even factors and display it as output.Example −Input : 30 Even dividers : 2+6+10+30 = 48 Output : 48For this, we will find all the factors. Find the even of them and find the sum, Else, we will use the formula to find the sum of factors using the prime factors, Sum of divisors = (1 + d11 + d12 ... d1a1) *(1 + d21 + d22 ... d2a2) *...........................* (1 + dk1 + dk2 ... dkak) Here di = prime factors ; ai ... Read More
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
2K+ Views
A sequence of characters or a linear array of character is known as String. Its declaration is same as define other arrays.Length of array is the number of characters in the String. There are many in-built method and other methods to find the length of string. Here, we are discussing 5 different methods to find the length of a string in C++.1) Using the strlen() method of C − This function returns an integer value of the C. For this you need to pass the string in the form of character array.PROGRAM TO ILLUSTRATE THE USE OF strlen() METHOD#include ... Read More
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
356 Views
The abs function in C++ is used to find the absolute value of a complex number. The absolute value of a complex number (also known as modulus) is the distance of that number from the origin in the complex plane. This can be found using the formula −For complex number a+bi:mod|a+bi| = √(a2+b2)The abs() function returns the result of the above calculation in C++. It is defined in the complex library that is needed to be included.PROGRAM TO SHOW USE OF abs() FUNCTION FOR COMPLEX NUMBERS IN C++#include #include using namespace std; int main () { float ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
772 Views
Here we will see some amazing results by using the system() function in C or C++. The system function is present in Windows, Linux and MAC operating systems. This function is used to execute the system commands that can be written in Command line.Here we will see two usages if system function in C or C++. The first one is getting the IP configuration details using C++ program.Example#include #include using namespace std; int main() { system("C:\Windows\System32\ipconfig"); }OutputWindows IP Configuration Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : domain.name Link-local IPv6 Address . . ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
223 Views
Here we will see how to calculate the number of trailing 0s for the result of factorial of any number. So if the n = 5, then 5! = 120. There is only one trailing 0. For 20!, it will be 4 zeros as 20! = 2432902008176640000.The easiest approach is just calculating the factorial and count the 0s. But this approach fails for large value of n. So we will follow another approach. The trailing zeros will be there, if the prime factors are 2 and 5. If we count the 2s and 5s we can get the result. For ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
101 Views
In this section we will see if one array is given with n numbers, we have to check if we make a number using all of the elements of these numbers, that number will be divisible by 3 or not. If the array elements are {15, 24, 23, 13}, then the we can make integer like 15242313. It will be divisible by 3.AlgorithmcheckDivThree(arr)Begin rem := 0 for each element e in arr, do rem := (rem + e) mod 3 done if rem is 0, then return true end ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
91 Views
The C++ has the String class. That is different than the traditional C strings. The C string is actually the character array. In C++, the string class has few different properties. It has different functions, that can be used to perform different tasks. Here we will see the important features of the String class.In the first section we will see how the constructors of the string class works in different way. Let us see by example.Example#include using namespace std; int main() { string str("This is a string"); cout