Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2168 of 3366
277 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 a 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. ... Read More
844 Views
We know that the excel column numbers are alphabetic. It starts from A, and after Z, it will AA, AB, to ZZ, then again AAA, AAB, to ZZZ and so on. So column 1 is A, column 27 is Z. Here we will see how to get the column letter if a number of columns is given. So if the column number is 80, then it will be CB.Suppose we have a number n, and its value is 28, then we need to take a reminder with 26. If the remainder is 0, then the number is 26, 52 and ... Read More
1K+ Views
Suppose we have an array; we have to check whether given number x is the majority element of that array or not. The array is sorted. One element is said to be the majority element when it appears n/2 times in the array. Suppose an array is like {1, 2, 3, 3, 3, 3, 6}, x = 3, here the answer is true as 3 is the majority element of the array. There are four 3s. The size of the array is 7, so we can see 4 > 7/2.We can count the occurrences of x in the array, and ... Read More
543 Views
Program DescriptionFloyd's triangle is a right-angled triangular array of natural numbers, used in computer science education. It is named after Robert Floyd. It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 in the top left corner1 15 14 13 12 11 2 3 10 9 8 7 4 5 6 6 ... Read More
4K+ Views
Program DescriptionA pyramid is a polyhedron formed by connecting a polygonal base and a point, called the apex. Each base edge and apex form a triangle, called a lateral face. It is a conic solid with polygonal base. A pyramid with an n-sided base has n + 1 vertices, n + 1 faces, and 2n edges. All pyramids are self-dual.AlgorithmAccept the number of rows from the user to form pyramid shape Iterate the loop till the number of rows specified by the user: Display 1 star in the first row Increase the number of stars based on the number of ... Read More
242 Views
Program DescriptionA pentatope number is a number in the fifth cell of any row of Pascal's triangle starting with the 5-term row 1 4 6 4 1 either from left to right or from right to left.The first few numbers of this kind are1, 5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365Pentatope numbers belong in the class of figurate numbers, which can be represented as regular, discrete geometric patterns. The formula for the nth pentatopic number is$$\left(\begin{array}{c}n+3\ 4\end{array}\right)=\left(\frac{n(n+1)+(n+2)+(n+3)}{24}\right)=\left(\frac{n^2}{4!}\right)$$AlgorithmAccept the Nth Term from the User to find the Pentotope Numbers.Use the formula$$\left(\begin{array}{c}n+3\ 4\end{array}\right)=\left(\frac{n(n+1)+(n+2)+(n+3)}{24}\right)=\left(\frac{n^2}{4!}\right)$$Example/* Program to print pentatope numbers ... Read More
1K+ Views
Suppose we have an array A, here A[i] is indicating the price of a given stock on day i. We have to find the maximum profit. We can complete as many transactions as we like. (Transaction means to buy and sell stocks). But we have to keep in mind that we may not engage in multiple transactions at the same time. So we have to sell the stock before buying the new one.Suppose the array is like A = [7, 1, 5, 3, 6, 4], then the result will be 7. As we can see, if we buy on day ... Read More
773 Views
Program DescriptionPrint the numeric pattern by accepting the number of rows from the user.Input: 5 Rows1 6 2 10 7 3 13 11 8 4 15 14 12 9 5AlgorithmPrint the pattern from the end of each Row Complete the last column of each Row Start from the Second Last Column of the second row Repeat till the number of rows specified by the User.Example/*Program to print Numeric Pattern */ #include int main() { int k, l, m, count=1; int rows; clrscr(); printf(" Please enter the number of rows for the Numeric Pattern: "); scanf("%d",&rows); for (k = 1; k
559 Views
Suppose we have an array A, here A[i] is indicating the price of a given stock on day i. We have to find the maximum profit. We can complete at most one transaction. (Transaction means to buy and sell stocks). But we have to keep in mind that we may not engage in multiple transactions at the same time. So we have to sell the stock before buying the new one.Suppose the array is like A = [7, 1, 5, 3, 6, 4], then the result will be 5. As we can see, if we buy on day 2 (index ... Read More
1K+ Views
Program DescriptionThe Diamond pattern is a combination of simple pyramid pattern and inverted pyramid pattern.AlgorithmFirst Row: Display 1 Second Row: Display 1,2,3 Third Row: Display 1,2,3,4,5 Fourth Row: Display 1,2,3,4,5,6,7 Fifth Row: Display 1,2,3,4,5,6,7,8,9 Display the same contents from 4th Row till First Row below the fifth Row.Example/* Program to print Diamond Pattern */ #include int main(){ int i,j,k; clrscr(); printf(""); printf("Diamond Pattern"); printf(""); printf(""); for(i = 1;i