C Program to find the Cartesian Product of Two Sets || Discreate Mathematics || C Progamming.

 


// C Program to find Cartesian Product of two number

#include <stdio.h>

int main() {

    int n1,n2,i,j,k,m;

    printf("Enter Your number of Element in Set A and Set B:\n");

    scanf("%d%d",&n1,&n2);

    int a[n1],b[n2];

    printf("Enter Your Element in Set A: \n");

    for(i=0;i<n1;i++)

    scanf("%d",&a[i]);

    printf("Enter Your Element in Set B: \n");

    for(j=0;j<n2;j++)

    scanf("%d",&b[j]);

    printf("Your cartesian product of two numbers is : \n");

    for(k=0;k<n1;k++)

    {

        for(m=0;m<n2;m++)

        {

            printf("(%d,%d) ",a[k],b[m]);

        }

    }

    

    return 0;

}

No comments:

Post a Comment

Operator Overloading in C++

#include<iostream> using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i = 0){       re...