Server Side Programming Articles - Page 1950 of 2650

Program to print pentatope numbers upto Nth term in C

suresh kumar
Updated on 09-Jan-2020 06:46:55

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

Best Time to Buy and Sell Stock II in Python

Arnab Chakraborty
Updated on 28-Apr-2020 09:32:06

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

Program to print numeric pattern in C

suresh kumar
Updated on 09-Jan-2020 06:43:20

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

Best Time to Buy and Sell Stock in Python

Arnab Chakraborty
Updated on 28-Apr-2020 09:29:33

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

Program to print Diamond Pattern in C

suresh kumar
Updated on 09-Jan-2020 06:41:00

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

Program to print numbers columns wise in C

suresh kumar
Updated on 09-Jan-2020 06:35:52

2K+ Views

Program DescriptionPrint the natural numbers columns wise as show below1 2 6 3 7 10 4 8 11 13 5 9 12 14 15Algorithmi stands for rows and j stands for columns. 5 stands for making pattern for 5 Rows and Columns Loop for each Row (i) K is initialized to i Loop for each Column (j) Do the Pattern for the current Column (j) Display the Value of K Reinitialize the Value of K = k + 5 - jExample/* Program to print the Natural Numbers in Columns wise */ #include int main(){    int i,j,k;    printf("Printing the Numbers in Columns wise: ");    printf("");    printf("");    for(i=1;i

Program to print number pattern in C

suresh kumar
Updated on 09-Jan-2020 06:39:18

2K+ Views

Program DescriptionA numerical pattern is a sequence of numbers that have been created based on a rule called a pattern rule. Pattern rules can use one or more mathematical operations to describe the relationship between consecutive numbers in the sequence.Examples for PatternsPattern 11 2 6 3 7 10 4 8 11 13 5 9 12 14 15Pattern 2 1 1 2 3 1 2 3 4 5 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 9 1 2 ... Read More

Print the Non Square Numbers in C

suresh kumar
Updated on 09-Jan-2020 06:36:43

7K+ Views

Program DescriptionThe square of a number is that number times itself.A square number or perfect square is an integer that is the square of an integer;The perfect squares are the squares of the whole numbers1, 4, 9, 16, 25, 36, 49, 64, 81, 100Here are the square roots of all the perfect squares from 1 to 100.√1 = 1 since 12 = 1 √4 = 2 since 22 = 4 √9 = 3 since 32 = 9 √16 = 4 since 42 = 16 √25 = 5 since 52 = 25 √36 = 6 since 62 = 36 √49 = 7 since 72 = 49 √64 = 8 ... Read More

Print multiplication table of a given number in C

suresh kumar
Updated on 09-Jan-2020 06:26:23

612 Views

Program DescriptionPrint multiplication table of a given numberAlgorithmAccept any number from the User for which we need to form multiplication table.Multiply the given number starting with the value of I (=1)Multiply the given number by incrementing the value of I till the I value is lesser than or equal to 12.Example/* Program to print the multiplication table of a given number */ #include int main() {    int number, i;    clrscr();    printf("Please enter any number to find multiplication table:");    scanf("%d", &number);    printf("Multiplication table for the given number %d: ", number);    printf("");    for(i=1;i

Program to Print Mirrored Hollow Parallelogram in C

suresh kumar
Updated on 09-Jan-2020 06:24:59

686 Views

Program DescriptionIt is a quadrilateral where both pairs of opposite sides are parallel.There are six important properties of parallelograms to knowOpposite sides are congruent (AB = DC).Opposite angels are congruent (D = B).Consecutive angles are supplementary (A + D = 180°).If one angle is right, then all angles are right.The diagonals of a parallelogram bisect each other.Each diagonal of a parallelogram separates it into two congruentAlgorithmAccept number of rows and columns from user. Store it in rows and cols variables.To iterate though rows, run an outer loop with the loop structure should look like for(r=1; r

Advertisements