Posts

Showing posts with the label C Programming

Top 10 Programming Language to learn in 2023

Are you a programming enthusiast looking to stay ahead of the curve in 2023? With the ever-evolving tech landscape, keeping up with the Best Programming Language to learn can be a daunting task. Fear not, as we have compiled a list of the top 10 Programming Languages that you should consider learning in 2023. Python: This versatile language continues to dominate in 2023, with its ease of use, readability, and a vast library of modules. JavaScript: As web development grows increasingly popular, JavaScript remains a crucial player, with its ability to create dynamic and interactive web pages. Java: This language has stood the test of time and remains a popular choice for enterprise software development. C++: A staple in the gaming and systems development industries, C++ offers exceptional performance and memory management. Swift: Apple's preferred language for iOS app development, Swift continues to grow in popularity with its simplicity and reliability. R: As data science and machin

Matrix Inverse: Matrix Inversion Technique

Image
Matrix Inversion Technique  The inverse of a matrix The inverse of a square n × n matrix A is another n × n matrix denoted by A -1  such that AA -1 =A -1 A=I where I is the n × n identity matrix. That is, multiplying a matrix by its inverse produces an identity matrix. Not all square matrices have an inverse matrix. If the determinant of the matrix is zero, then it will not have an inverse, and the matrix is said to be singular. Only non-singular matrices have inverses. A formula for finding the inverse Given any non-singular matrix A, its inverse can be found from the formula A -1  = adj A |A| where adj A is the adjoint matrix and |A| is the determinant of A. The procedure for finding the adjoint matrix is given below. Finding the adjoint matrix The adjoint of a matrix A is found in stages: Find the transpose of A, which is denoted by A T . The transpose is found by interchanging the rows and columns of A. So, for example, the first column of A is the first row of the transpo

Expression, Statements and Comments in C Programming | C Programming

Image
Expression, Statements, and Comments in C Programming  Arithmetic C Expressions in C Programming An expression is a combination of variables constants and operators written according to the syntax of the C language. In C every expression evaluates to a value i.e., every expression results in some value of a certain type that can be assigned to a variable. Some examples of C expressions are shown in the table given below. Algebraic C Expression in C programming Expression a x b - ca * b – c (m + n) (x + y) (m + n) * (x + y) (ab / c)a * b / c 3x2 +2x + 13*x*x+2*x+1 (x / y) + cx / y + c Evaluation of Expressions in C Programming Expressions are evaluated using an assignment statement of the form Variable = expression; Variable is any valid C variable name. When the statement is encountered, the expression is evaluated first and then replaces the previous value of the variable on the left-hand side. All variables used in the expression must be assigned values before evaluation

C Program to Print Triangle Pattern | C Programming

Image
To draw the kite pattern, we use for a loop. The kite Pattern in c is easy to make using for loop. A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Syntax The syntax of a for loop in C programming language is for ( init; condition; increment ) { statement(s); } Here is the flow of control in a 'for' loop − The init step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears. Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and the flow of control jumps to the next statement just after the 'for' loop. After the body of the 'for' loop executes, the flow of control jumps back up to the increment statement. This statement allows you to update any loop cont

Introduction to the C programming Language

Image
  Introduction:- ±    C is a general-purpose high-level language ±    Father of C – Dennis Ritchie ±    Originally developed for the UNIX operating system ±    Implemented on the Digital Equipment Corporation, PDP-11 computer in 1972 ±    The UNIX operating system and all UNIX applications are written in the C language   C has now become a widely used professional language for various reasons: ±     Easy to learn ±     Structured language ±     It produces efficient programs ±     It can handle low-level activities ±     It can be compiled on a variety of computers Why we use C? ±    C was initially used for system development work, in particular the programs that make-up the operating system ±    C was adopted as a system development language because it produces code that runs nearly as fast as code written in assembly language. ±    Some examples of the use of C might be: °     Operating Systems °     Language Compilers  °     Assemblers °     Text Editors °     Network Drivers °   

C Program For Prim's Algorithm To Find Shortest Path | C Programming

Image
C Program For Prim's Algorithm To Find Shortest Path #include <stdio.h> #include <stdlib.h> #define infinity 9999 #define MAX 20 int G [ MAX ][ MAX ], spanning [ MAX ][ MAX ], n ; int prims (); int main () {     int i , j , total_cost ;     printf ( "Enter no. of vertices:" );     scanf ( " %d " , & n );     printf ( " \n Enter the adjacency matrix: \n " );     for ( i = 0 ; i < n ; i ++)         for ( j = 0 ; j < n ; j ++)             scanf ( " %d " , & G [ i ][ j ]);     total_cost = prims ();     printf ( " \n spanning tree matrix: \n " );     for ( i = 0 ; i < n ; i ++)     {         printf ( " \n " );         for ( j = 0 ; j < n ; j ++)             printf ( " %d \t " , spanning [ i ][ j ]);     }     printf ( " \n\n Total cost of spanning tree= %d " , total_cost );     return 0 ; } int prims () {     int cost [ MAX ][ MAX ];     int u ,

C Program To Sort The Words In Alphabetical Order | C Programming

Image
C Program To Sort The Words In Alphabetical Order #include <stdio.h> #include <string.h> int main () {     int i , j , n ;     char str [ 25 ][ 25 ], temp [ 25 ];     puts ( "How many strings you are going to enter?: " );     scanf ( " %d " , & n );     puts ( "Enter Strings one by one: " );     for ( i = 0 ; i <= n ; i ++)     {         gets ( str [ i ]);     }     for ( i = 0 ; i <= n ; i ++)         for ( j = i + 1 ; j <= n ; j ++)         {             if ( strcmp ( str [ i ], str [ j ]) > 0 )             {                 strcpy ( temp , str [ i ]);                 strcpy ( str [ i ], str [ j ]);                 strcpy ( str [ j ], temp );             }         }     printf ( "Order of Sorted Strings:" );     for ( i = 0 ; i <= n ; i ++)         puts ( str [ i ]);     return 0 ; } OUTPUT

Variables in C

Image
Variables in C Programmings:- "Variable in C" variables names are case sensitive whose value can change any time. It is a memory location used to store data value. A variable name in C variables should be carefully chosen so that its use is reflected in a useful way in the entire program.  Rules for declaring variables in C Programming:- They must always begin with a letter, although some systems permit underscore as the first character. The length of a variable must not be more than 8 characters. White space is not allowed and A variable should not be a Keyword It should not contain any special characters.  In C variables A variable declaration provides assurance to the compiler that there exists a variable with the given type and name so that the compiler can proceed for further compilation without requiring the complete detail about the variable. A variable definition has its meaning at the time of compilation only, the compiler needs actual variable

C program to calculate Chinese remainder theorem | C Programming

C program to calculate the Chinese remainder theorem  #include <stdio.h> int main () {     int user_num [ 2 ];     int numbers [ 4 ];     int a [ 10 ][ 10 ];     int i , j , sum [ 4 ];     printf ( " \n Enter two numbers of seven digits: \n " );     for ( i = 0 ; i <= 1 ; i ++)     {         scanf ( " %d " , & user_num [ i ]);     }     printf ( " \n\n Enter four relative prime numbers: \n " );     for ( i = 0 ; i < 4 ; i ++)     {         scanf ( " %d " , & numbers [ i ]);     }     for ( i = 0 ; i < 2 ; i ++)     {         for ( j = 0 ; j < 4 ; j ++)         {             a [ i ][ j ] = user_num [ i ] % numbers [ j ];         }     }     for ( i = 0 ; i < 4 ; i ++)     {         j = 0 ;         sum [ i ] = ( a [ j ][ i ] + a [ j + 1 ][ i ]) % numbers [ i ];     }     printf ( " \n\n The tuple of 4 numbers is: \n\n " );     printf ( "(" );     for ( i = 0 ; i < 4

C Program To Generate Permutation And Combination | C Programming

C Program To Generate Permutation #include <stdio.h> long int fact ( int x ) {     long int f = 1 ;     int i ;     for ( i = 1 ; i <= x ; i ++)         f = f * i ;     return ( f ); } int main () {     int n , r , i , p ;     printf ( "Enter value of n and r : " );     scanf ( " %d %d " , & n , & r );     if ( n >= r )     {         p = fact ( n ) / fact ( n - r );         printf ( "Permutation P( %d , %d ) = %d " , n , r , p );     }     else     {         printf ( "Wrong Input ! Enter n>=1 ." );     }     return 0 ; } C Programming To Generate Combination | C Programming #include <stdio.h> long int fact ( int x ) {     long int f = 1 ;     int i ;     for ( i = 1 ; i <= x ; i ++)         f = f * i ;     return ( f ); } int main () {     int n , r , i , ncr ;     printf ( "Enter value of n and r : " );     scanf ( " %d %d " , & n , & r );

C Program To Compute A Power N and C Program To Find GCD Using Recursion | C Programming

C Program To Compute A Power N #include <stdio.h> int power ( int a , int n ) {     if ( n == 0 )     {         return 1 ;     }     else     {         return a * power ( a , n - 1 );     } } int main () {     int a , n , x ;     printf ( "Enter a non-zero real number: " );     scanf ( " %d " , & a );     printf ( "Enter positive power: " );     scanf ( " %d " , & n );     x = power ( a , n );     printf ( "The value of %d ^ %d = %d " , a , n , x ); } C Program To Find GCD Using Recursion #include <stdio.h> int hcf ( int n1 , int n2 ); int main () {     int n1 , n2 ;     printf ( "Enter values of a and b : " );     scanf ( " %d %d " , & n1 , & n2 );     printf ( "G.C.D ( %d , %d ) = %d ." , n1 , n2 , hcf ( n1 , n2 ));     return 0 ; } int hcf ( int n1 , int n2 ) {     if ( n2 != 0 )         return hcf ( n2 , n1 % n2 );     else        

Popular posts from this blog

C program to Find Cartesian Product of Two Sets | C programming

Array in C Programming | C Programming

What is System? | SAD