Posts

Showing posts from September 30, 2018

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 Find implication | C++ Programming

Implication:- The statement “p implies q” means that if p is true, then q must also be true. The statement “p implies q” is also written “if p then q” or sometimes “q if p.” Statement p is called the premise of the implication and q is called the conclusion.

C++ Program for modular search and linear search using recursion function | C++ Programming

C++ Program for modular search and linear search using recursion function Before starting with the program to find binary search and linear search using recursion function let us know about recursion function and Modular Search. Recursion Function Recursion is a process by which a function call itself repeatedly until some specified condition has been satisfied.                  The process is used for repetitive computation in which action is stated in terms of previous result.                  In order to solve a problem recursively two condition must be satisfied. The problem must be written in a recursive form. The problem statement must include a problem stopping condition.

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        

C Program for Binary Search and Merge Search using recursion function | C Programming

C Program for Binary Search and Merge Search using recursion function Before starting with the program to find binary search and linear search using recursion function let us know about recursion function. Recursion Function Recursion is a process by which a function call itself repeatedly until some specified condition has been satisfied.                  The process is used for repetitive computation in which action is stated in terms of previous result.                  In order to solve a problem recursively two condition must be satisfied. The problem must be written in a recursive form. The problem statement must include a problem stopping condition.