Found 1339 Articles for C

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

605 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

666 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

Print the Mirror Image of Sine-Wave Pattern in C

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

387 Views

Program DescriptionA sine wave or sinusoid is a mathematical curve that describes a smooth periodic oscillation. A sine wave is a continuous wave. It is named after the function sine, of which it is the graph. It occurs often in pure and applied mathematics, as well as physics,  engineering,  signal processing and many other fields.Print the Mirror Image of Sine-Wave Pattern based on the Wave Height and Wave LengthAlgorithmAccept the Wave Height and Wave LengthPrint the Wave Sign for the Wave Height and the Wave Length.Example/* Program to print the mirror image of Sine Wave*/ #include int main(){    int wave_height;    int wave_length;    int i, j, k;    clrscr(); /*Clears the ... Read More

Program to Print the Squared Matrix in Z form in C

suresh kumar
Updated on 09-Jan-2020 06:15:07

678 Views

Program DescriptionPrint the elements of the squared matrix in Z formA square matrix is a matrix with the same number of rows and columns. An n-by-n matrix is known as a square matrix of order AlgorithmTo print the elements of the Square Matrix in Z form We need to print the first row of matrix then diagonal and then last row of the square matrix.Example/* Program to print a square matrix in Z form */ #include int main(){    int rows, cols, r, c, matrix[10][10];    clrscr(); /*Clears the Screen*/    printf("Please enter the number of rows for the Square matrix: ... Read More

Program to print Lower triangular and Upper triangular matrix of an array in C

suresh kumar
Updated on 13-Jul-2020 11:53:43

13K+ Views

Program DescriptionWrite a program to print lower triangular matrix and upper triangular matrix of an Array.Triangular MatrixA Triangular matrix is one that is either lower triangular or upper triangular.Lower Triangular MatrixA square matrix is called lower triangular if all the entries above the main diagonal are zero.Upper Triangular MatrixA square matrix is called upper triangular if all the entries below the main diagonal are zero.A matrix of the form$${\displaystyle L={\begin{bmatrix}\ell _{1, 1}&&&&0\\ell _{2, 1}&\ell _{2, 2}&&&\\ell _{3, 1}&\ell _{3, 2}&\ddots &&\\vdots &\vdots &\ddots &\ddots &\\ell _{n, 1}&\ell _{n, 2}&\ldots &\ell _{n, n-1}&\ell _{n, n}\end{bmatrix}}}$$is called a lower triangular matrix or left triangular matrix, and analogously a matrix of the form$${\displaystyle U={\begin{bmatrix}u_{1, 1}&u_{1, 2}&u_{1, ... Read More

C/C++ difference's between strncmp() and strcmp.

Mahesh Parahar
Updated on 06-Jan-2020 06:35:51

374 Views

strncmp() and strcmp compares two strings using ASCII character comparison. strncmp takes one additional parameter as number to characters upto which a string is to be compared. It is very useful as if a string is not valid, then strcmp will not be able to complete its operation. strcmp searches for end character ('/0') at string end to finish its operation. strncmp uses no. of characters to end its operation and thus is safe.Example#include int main() {    char str1[] = "TutorialsPoint";    char str2[] = "Tutorials";    // Compare strings with strncmp()    int result1 = strncmp(str1, str2, ... Read More

Advertisements