C Program to find Cartesian Product of two sets

Wednesday, 4 September 2013

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],b[10],c[10],i,j,k;clrscr();
printf("enter d elements in set a");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
}
printf("enter d elements in set b");
for(j=0;j<5;j++)
{
scanf("%d",&b[j]);
}
printf("cartessian product=");
printf("{");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("(%d,%d)",a[i],b[j]);
printf(",");
}}
printf("}");
getch();
}

OUTPUT:-

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Related Posts Plugin for WordPress, Blogger...
 

Most Reading

Labels