Found 1401 Articles for C

Print multiplication table of a given number in C

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

487 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

496 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

207 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

541 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

12K+ 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

220 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

Difference between const char* p, char * const p, and const char * const p in C

Mahesh Parahar
Updated on 06-Jan-2020 06:30:36

11K+ Views

PointerIn C programming language, *p represents the value stored in a pointer and p represents the address of the value, is referred as a pointer.const char* and char const* says that the pointer can point to a constant char and value of char pointed by this pointer cannot be changed. But we can change the value of pointer as it is not constant and it can point to another constant char.char* const says that the pointer can point to a char and value of char pointed by this pointer can be changed. But we cannot change the value of pointer ... Read More

Difference between const int*, const int * const, and int const * in C

Mahesh Parahar
Updated on 06-Jan-2020 06:27:49

4K+ Views

PointerIn C programming language, *p represents the value stored in a pointer and p represents the address of the value, is referred as a pointer.const int* and int const* says that the pointer can point to a constant int and value of int pointed by this pointer cannot be changed. But we can change the value of pointer as it is not constant and it can point to another constant int.const int* const says that the pointer can point to a constant int and value of int pointed by this pointer cannot be changed. And we cannot change the value ... Read More

Difference between %d and %i format specifier in C language.

Mahesh Parahar
Updated on 06-Jan-2020 06:22:05

12K+ Views

Format SpecifiersIn C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs. scanf() function detects base using %i but assumes base 10 using %d.Example (C) Live Demo#include int main() {    int num1 ,num2;    int num3, num4;    scanf("%i%d", &num1 , &num2);    printf("%i\t%d", num1, num2);    num3 = 010;    num4 = 010;    printf("%i\t%d", num3, num4); ... Read More

C/C++ difference's between "int main()" and "int main(void)"

Mahesh Parahar
Updated on 06-Jan-2020 06:19:29

765 Views

CIn C programming language, if a function signature is not having any parameters then it can take multiple arguments as input but the same is not true with C++. The compilation will fail if arguments are passed to such a function in C++. This is reason int main() and int main(void) are same in C, but int main(void) is better approach, which restricts the user to pass multiple arguments to main function.Example (C) Live Demo#include int main() {    static int counter = 3;    if (--counter){       printf("%d ", counter);       main(5);    } }Output2 ... Read More

Advertisements