Posts

C++ Program To Find Factorial Of Two Numbers Using Recursion Function | C++ Programming

C++ Program To Find Factorial Of Two Numbers Using Recursion Function #include<iostream> using namespace std; long int fact(int); int main() { int n1,n2; cout<<"Enter number"< cin>>n1>>n2; cout<<n1<<"! = "<<fact(n1)<<endl; cout<<n2<<"! = "<<fact(n2)<<endl; } long int fact(int n) { if(n<=1) return 1; else   return (n*fact(n-1)); } OUTPUT Enter number 5 4 5! = 120 4! = 24

Type Conversion In C++

Type Conversion The type conversions are automatic as long as the data types involved are built-in types. If the data types are user-defined, the compiler does not support automatic type conversion and therefore, we must design the conversion routines by ourselves. Three types of situations might arise in the data conversion in this case. 1. Conversion from basic type to class type 2. Conversion from class type to basic type 3. Conversion from one class type to another class type

C++ Program To Multiply Matrices | C++ Programming

C++ Program To Multiply Matrices #include<iostream> using namespace std; class Matrix { private: int a[10][10]; public: void read_matrix(int m, int n); void display_matrix(int m, int n); void multiply_matrix(int ,int, int,Matrix x, Matrix y); }; void Matrix::read_matrix(int m,int n) { for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { cin>>a[i][j]; } } } void Matrix::display_matrix(int m,int n) { for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { cout<<a[i][j] <<"\t"; } cout<<endl; } } void Matrix::multiply_matrix(int r1,int c1, int c2, Matrix x, Matrix y) {  for(int i=0; i<r1; i++)     { for(int j=0; j<c2; j++)         {         a[i][j]=0; for(int k=0;k<c1;k++)         {         a[i][j]+=x.a[i][k]*y.a[k][j]; }  } } } int main() { int r1,c1,r2,c2; cout<<"Enter order of first matrix: "; cin>>r1>>c1; cout<<"Enter order of seond matrix: "; cin>>r2>>c2; Matrix mat1,

C++ Program To Calculate Tax Using Constructor and Destructor | C++ Programming

C++ Program To Calculate Tax Using Constructor and Destructor  Calculating the tax using the C++ program is easy if you have the concept of constructor and destructor. There is also another way to calculate Tax using C++ which is simple but the use of a constructor is much more practical in the programming world. Let us have some knowledge about the class constructor and destructor below.

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

Image
C program to find the Cartesian Product of two sets   Cartesian product  is a mathematical operation that returns a set (or  product set  or simply  product ) from multiple sets. That is, for sets  A  and  B , the Cartesian product  A  ×  B  is the set of all ordered pairs  ( a ,  b )  where  a  ∈  A  and  b  ∈  B . Products can be specified using set-builder notation, e.g. {\displaystyle A\times B=\{\,(a,b)\mid a\in A\ {\mbox{ and }}\ b\in B\,\}.}

C program To Calculate The Intersection Of Two Sets | Union Of Two Sets | Differences Between Two Sets And Symmetric Difference Of Two Sets | C Programming

This Program helps to calculate intersection of two sets, union of two sets, differences of two sets and symmetric difference of two sets using one simple program in which different variables are declared so that it can be useful to find intersection of two sets, union of two sets, differences of two sets and symmetric difference of two sets Codes #include <stdio.h> int a [ 10 ], b [ 10 ], c [ 10 ], d [ 10 ], i , j , k = 0 , n , m , flag = 0 ; void unio () {     for ( i = 0 ; i < n ; i ++)     {         c [ k ] = a [ i ];         k ++;     }     for ( i = 0 ; i < m ; i ++)     {         flag = 0 ;         for ( j = 0 ; j < n ; j ++)         {             if ( b [ i ] == a [ j ])             {                 flag = 1 ;                 break ;             }         }         if ( flag == 0 )         {             c [ k ] = b [ i ];             k ++;         }     }     printf ( " \n Union \n " );     for ( i = 0 ; i < k ; i ++)

C Program To Calculate Age and Compare Using Concept of Fuzzy Set | C Programming

C Program To Calculate Age and Compare Using Concept of Fuzzy Set  #include <stdio.h> int i , age [ 5 ]; float a [ 5 ], b [ 5 ], c [ 5 ]; char name [ 5 ][ 15 ]; void unio () {     for ( i = 0 ; i < 5 ; i ++)     {         if ( a [ i ] >= b [ i ])             c [ i ] = a [ i ];         else             c [ i ] = b [ i ];     }     printf ( "union \n " );     printf ( "{ " );     for ( i = 0 ; i < 5 ; i ++)     {         printf ( " %.2f / %s ," , c [ i ], name [ i ]);     }     printf ( "}" ); } void intersection () {     for ( i = 0 ; i < 5 ; i ++)     {         if ( a [ i ] <= b [ i ])             c [ i ] = a [ i ];         else             c [ i ] = b [ i ];     }     printf ( " \n intersection \n " );     printf ( "{" );     for ( i = 0 ; i < 5 ; i ++)     {         printf ( " %.2f / %s , " , c [ i ], name [ i ]);     }     printf ( "}" ); } void comple