Skip to main content

Posts

Showing posts from September, 2021

Overview of C - Notes

 Overview of C - Notes   Importance of C Programming:   C is a robust language and has a rich set of built in functions, data types and operators which can be used to write any complex programs. Program written in C are efficient and fast due to availability of several data types and operators. C has the capability of an assembly language with the feature of high level language, so it is well suited for writing in both system software and application software. C is highly portable language, code written in one machine can be moved to other which is very important and powerful feature. C also supports low level features like bit level programming. C has high level constructs and it is more user friendly as its syntaxes approaches to English like language. History of C Language:                 In 1972, Dennis Ritchie developed a programming language at the AT&T Bell Laboratories in USA, called C Language. It was developed to be used in UNIX operating system. Dennis Ritchie

C program to reverse a number entered by the user

 C program to reverse a number entered by the user     In this example, we will display the reverse of a number entered by the user. Here, in the output we have entered a number 472 whose reverse will be displayed in the screen. C PROGRAM TO REVERSE A NUMBER ENTERED BY THE USER: #include <stdio.h> #include <conio.h> void  main() {      int  x,y=0,r;     printf( "Enter a number : " );     scanf( "%d" ,&x);      while (x!=0)     {         r=x%10;         y=y*10+r;         x=x/10;     }     printf( "Reverse is : %d" ,y);     getch(); } OUTPUT TO REVERSE A NUMBER ENTERED BY THE USER:      Enter a number: 472      Reverse is : 274 NOTE:   You Can Comment Your Code if you have solved differently and we will pin it in the comment section.  Let's Learn together.  MOTTO:                           You Learn, I Learn together We Learn.  

C program to read m x n matrix and calculate the Row sum and Column sum of the matrix.

 C program to read m x n matrix and calculate the Row sum and Column sum of the matrix.     In this example, we read a m x n matrix whose value would be entered by the user then the sum of row and column is calculated. Here in the example we have taken a matrix of order 3 x 2 whose row sum and column sum is displayed in the output screen. PROGRAM TO READ m x n MATRIX AND CALCULATE THE ROW SUM AND COLUMN SUM OF THE MATRIX: #include <stdio.h> #include <conio.h> void  main() {      int  i,j,m[100][100],row,column,rsum,csum=0;     printf( "Enter the row size of the matrix :" );     scanf( "%d" ,&row);     printf( "Enter the column size of the matrix :" );     scanf( "%d" ,&column);     printf( "Enter the Matrix : " );      for (i=0;i<row;i++)     {          for (j=0;j<column;j++)         {             scanf( "%d" ,&m[i][j]);         }     }      for (i=0;i<row;i++)     {         rsum=0;         

C Program to check if a given square matrix is symmetric or not using function

 C Program to check if a given square matrix is symmetric or not using function.     In this example, we will check if a given square matrix entered by the user is symmetric or not. Here in the output we have taken a square matrix of 3x3. PROGRAM TO CHECK IF A GIVEN SQUARE MATRIX IS SYMMETRIC OR NOT USING FUNCTION #include <stdio.h> #include <conio.h> void  symmetric( int , int , int  [50][50]); void  main() {      int  row,column,i,j,a[50][50];     printf( "Enter the size of the matrices: " );     scanf( "%d" ,&row);     column=row;     printf( "Enter the matrix : " );      for (i=0;i<row;i++)     {          for (j=0;j<column;j++)         {             scanf( "%d" ,&a[i][j]);         }     }     symmetric(row,column,a);     getch(); } void  symmetric( int   r , int   c , int   f [50][50]) {      int  flag=1,i,j,t[50][50];      for (j=0;j< c ;j++)     {          for (i=0;i< r ;i++)         {             t[i][j]=

C program to display the upper triangle and lower triangle of the given square Matrix using function

 C program to display the upper triangle and lower triangle of the given square Matrix using function     In this example, we will display the upper triangle and lower triangle of a given square matrix using function. Here in the output section we have taken a 3x3 matrix whose values are entered as shown in the output. After entering the elements of the square matrix it will display the upper triangle and lower triangle of the matrix entered. PROGRAM TO DISPLAY THE UPPER TRIANGLE AND LOWER TRIANGLE OF THE GIVEN SQUARE MATRIX USING FUNCTION #include <stdio.h> #include <conio.h> void  uppert( int , int , int  [100][100]); void  lowert( int , int , int  [100][100]); void  main() {      int  i,j,c,d,a[100][100];     printf( "Enter the size of the given square matrix : " );     scanf( "%d" ,&c);     d=c;     printf( "Enter the Matrix : " );      for (i=1;i<=c;i++)     {          for (j=1;j<=d;j++)         {              scanf( "%d&qu

C program to convert a decimal number into binary number using function.

 C program to convert a decimal number into binary number using function.     In this example, we  convert the decimal number entered by the user into binary form. Here, in the out put we have taken a decimal number 20 whose binary  is printed as 10100. You can take other numbers such as 15, 13 78, etc... PROGRAM TO CONVERT A DECIMAL NUMBER INTO BINARY NUMBER USING FUNCTION. #include   <stdio.h> #include <conio.h> int  binary( int   b ); void  main() {      int  b;     printf( "\nEnter the Number You want to convert : " );     scanf( "%d" , &b);     binary(b);     getch(); } int  binary( int   b ) {      int  a[10], i, j;      for  (i = 0;  b  > 0; i++)     {         a[i] =  b  % 2;          b  =  b  / 2;     }     printf( "\n Binary Number of a Given Number =  " );      for  (j = i - 1; j >= 0; j--)     {         printf( "%d" , a[j]);     }     printf( "\n" );      return  0; } OUTPUT  TO CONVERT A DECIMAL NUMBER

C Program to print the PASCAL Triangle up to the Nth row where n is a value inputted by the user

 C Program to print the PASCAL Triangle up to the Nth row where n is a value inputted by the user.  .    In this example, we will print a Pascal's triangle upto to the value of the Nth row entered by the user. In the output section we have taken the value of n as 6 and the pascal's triangle is shown in the output. No, it is not that you have to take the value of n as 6, you can enter any value according to your choice. And the required pascal's tringle will be available on the screen.   What is Pascal's Triangle? Pascal's Triangle is a triangular arrangement of the binaomaial coefficients of the expansion (x+y) n  for positive integral values of n. PROGRAM  TO PRINT THE PASCAL TRIANGLE UP TO THE N-TH ROW WHERE N IS A VALUE INPUTTED BY THE USER: #include <stdio.h> #include <conio.h> void  main() {      int  n,coef=1,space,i,j;     printf( "Enter the value of n:" );             scanf( "%d" ,&n);      for (i=0;i<n;i++)     {