Top 10 Programming Language to learn in 2023

Are you a programming enthusiast looking to stay ahead of the curve in 2023? With the ever-evolving tech landscape, keeping up with the Best Programming Language to learn can be a daunting task. Fear not, as we have compiled a list of the top 10 Programming Languages that you should consider learning in 2023. Python: This versatile language continues to dominate in 2023, with its ease of use, readability, and a vast library of modules. JavaScript: As web development grows increasingly popular, JavaScript remains a crucial player, with its ability to create dynamic and interactive web pages. Java: This language has stood the test of time and remains a popular choice for enterprise software development. C++: A staple in the gaming and systems development industries, C++ offers exceptional performance and memory management. Swift: Apple's preferred language for iOS app development, Swift continues to grow in popularity with its simplicity and reliability. R: As data science and machin

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


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 (ab) where a ∈ A and b ∈ B. Products can be specified using set-builder notation, e.g.



Let us take an example of 3✕3 Cartesian products: -


Let A = {a, b, c} and B = {d, e, f}
The Cartesian product of two sets is
A x B = {a, d}, {a, e}, {a, f}, {b, d}, {b, e}, {b, f}, {c, d}, {c, e}, {c, f}}



Concept For the Code:-

In this program we declare 3 arrays a, b, and c of length 50, now we declare variables i, s1, s2, j, and k. Now we ask all the variable's values from the user to compute the Cartesian product. The use of For Loop is to take out the Cartesian product until the user inputted condition is met.

CODES

#include <stdio.h>
#include <conio.h>
int main()
{
    int a[50], b[50], c[50], i, s1, s2, j, k;
    printf("Enter how many elements in set 1\n");
    scanf("%d", &s1);
    printf("Enter how many elements in set 2\n");
    scanf("%d", &s2);
    printf("Enter elements of set 1\n");
    for (i = 0; i < s1; i++)
    {
        scanf("%d", &a[i]);
    }
    printf("Enter elements of set 2\n");
    for (i = 0; i < s2; i++)
    {
        scanf("%d", &b[i]);
    }
    printf("cartessian product=");
    printf("{");
    for (i = 0; i < s1; i++)
    {
        for (j = 0; j < s2; j++)
        {
            printf("(%d,%d)", a[i], b[j]);
            printf(",");
        }
    }
    printf("}");
}

Comments

Popular posts from this blog

Array in C Programming | C Programming

What is System? | SAD