0% found this document useful (0 votes)
20 views2 pages

Labwork 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Labwork 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

2.

solution

For cartesian products

//Program to find the cartesian product

#include <stdio.h>

#include <conio.h>

int main()

int a[100], b[100], c[100], i,j,m,n;

printf ("How many elements in set A: ");

scanf ("%d", &m);

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

printf ("\nEnter the %d element: ", i+1);

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

printf ("\nHow many elements in set B: ");

scanf ("%d", &n);

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

printf ("\nEnter the %d element: ", j+1);

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

printf ("\nThe cartesian product is: ");

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

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

{
printf ("{%d,%d}, ", a[i], a[j]);

return 0;

You might also like