Skip to main content

Posts

Showing posts from September, 2017

Difference of Two Sets (B - A)

// B difference A #include <stdio.h> #define SIZE 10 void display(int disp[]) {     int i;     for(i=0;disp[i];i++)     {         printf(" %d ", disp[i]);     } } int main() {     int i,j,k=0, flag,elem1, elem2;     int a[SIZE];     int b[SIZE];     int c[SIZE]={'\0'};     printf("Enter the Number of Members of Set A : ");     scanf("%d", &elem1);     for(i=0;i<elem1 && elem1 < SIZE;i++)     {         printf("a[%d] = ", i);         scanf("%d",&a[i]);     }     a[i]='\0';     printf("Enter the Number of Members of Set B : ");     scanf("%d", &elem2);     for(i=0;i<elem...

Difference of Two Sets (A - B)

// A difference B #include <stdio.h> #define SIZE 10 void display(int disp[]) {     int i;     for(i=0;disp[i];i++)     {         printf(" %d ", disp[i]);     } } int main() {     int i,j,k=0, flag,elem1, elem2;     int a[SIZE];     int b[SIZE];     int c[SIZE]={'\0'};     char ch='y';     printf("Enter the Numbers of A : ");     scanf("%d", &elem1);     for(i=0;i<elem1 && elem1 < SIZE;i++)     {         printf("Enter a[%d] = ", i);         scanf("%d",&a[i]);     }     a[i]='\0';     printf("Enter the Values of B : ");     scanf("%d", &elem2);     for(i=0;i...

Union of Two Sets

// A Union B #include <stdio.h> #define SIZE 10 void display(int disp[]) {     int i;     for(i=0;disp[i];i++)     {         printf(" %d ", disp[i]);     } } int main() {     int i,j,k=0, flag,elem1, elem2;     int a[SIZE];     int b[SIZE];     int c[SIZE]={'\0'};     char ch='y';     printf("Enter the Elements of A : ");     scanf("%d", &elem1);     printf("Enter the value for A : ");     for(i=0;i<elem1 && elem1 < SIZE;i++)     {         printf("a[%d] = ", i);         scanf("%d",&a[i]);     }     a[i]='\0';     printf("Enter the Elements of B : ");     scanf...

Count Elements

// Counting Elements #include<stdio.h> #define SIZE 10 void count(); int main() {     int a[SIZE] = {'\0'};     int i,n;     printf("Enter the Number of Elements [Max = %d] : ",SIZE);     scanf("%d",&n);     if(n>SIZE)     {         printf("INVALID INPUT !! ");     }     else     {         for(i=0; i<n; i++)         {             printf("Enter the Elements a[%d] : ",i);             scanf("%d",&a[i]);         }         count(a);     }     return 0; } void count(int a[]) {     int i;     for(i=0;a[i];i++);     printf("\nTotal Number of Elements Are : %d",i); }

Intersection of Two Sets

// Intersection of Two Sets #include<stdio.h> #define SIZE 10 int main() {     int a[SIZE],b[SIZE],i,j,m,n;     printf("Enter the Number of Elements in A : ");     scanf("%d",&m);     printf("Enter the Number of Elements in B : ");     scanf("%d",&n);     printf("\nSET-A\n");     for(i=0;i<m;i++)     {         printf("Enter the Elements a[%d] : ",i);         scanf("%d",&a[i]);     }     printf("\nSET- B\n");     for(j=0;j<n;j++)     {         printf("Enter the Elements b[%d] : ",j);         scanf("%d",&b[j]);     }     printf("\nA intersection B : {");     for(i=0;i<m;i++)     {         for(j=0;j<n;j++)         {          ...

Search an Element

// Searching an Element #include<stdio.h> #define SIZE 10 void search(int a[],int no) {    int i, flag = 0;    for(i=0;i<=a[i];i++)    {        if(no == a[i])        {            printf("%d Found at Position %d And Index No is %d",no,i+1,i);            flag=1;        }    }    if(!flag)    {        printf("%d not Found!!",no);    } } int main() {    int i,no,elements;    int a[SIZE];    printf("Enter a Number of Elements : ");    scanf("%d",&elements);    for(i=0;i<elements;...