Search This Blog

Showing posts with label of. Show all posts
Showing posts with label of. Show all posts

Algorithm and C Program to Find Closure From Functional Dependencies

In this post we will see how to find closure of an attribute or a set of attributes. Before learning how to get closure, we should first know what is a closure. Closure of a given set C is the set of attributes that are functionally determined by the set C under the set of functional dependencies F. There can be closure for any set. Every attribute in the set whose closure is to be found out, will be a member of its closure set C+ also. Consider an example:

How to use fork and exec System Call

Using fork and exec System calls in Linux (UNIX) operating systems. Fork system call is used to create a child process from a parent process.
#include<stdio.h>
main()
{

int pid;
pid=fork();
printf("%d\n",pid);
if(pid==0)
{
exec("/bin/date\n",NULL,NULL);
exit(0); }
else
{
printf("Parent process %d\n",pid); }}
if(sp)
while(dd=readdir(sp))
printf("--> %s\n",dd->d_name);
}
}

Determinant of Matrix Program - Program to Find Determinant of Matrix

In this post i am sharing a C program to calculate determinant of matrices. Determinant exists only for square matrix. Here i have wrote a c program to find determinant of matrices of order less than or equal to 3.

#include<stdio.h>
void main() { int a[10][10],i,m,j; int det=0; printf("\nEnter the order of matrix:\n "); scanf("%i",&m); printf("\nenter elements\n"); for(i=0;i<m;i++)  {  for(j=0;j<m;j++)   scanf("%d",&a[i][j]);  } printf("\nThe matrix is\n"); for(i=0;i<m;i++)  {  printf("\n");  for(j=0;j<m;j++)   printf("%3d",a[i][j]);  } printf("\nthe transpose is\n"); for(i=0;i<m;i++) { for(j=0;j<m;j++) printf("%3i",a[j][i]); printf("\n"); } if(m==1) { det=a[0][0]; printf("det=%i",det); } else if(m==2) { int k=1,l=1; for(i=0;i<2;i++) for(j=0;j<2;j++) { if(i==j) k*=a[i][j]; else l*=a[i][j]; } printf("\ndeterminant=%i",k-l); } else if(m==3) { for(i=0;i<3;i++) det=det+(a[0][i]*(a[1][(i+1)%3]*a[2][(i+2)%3]-a[1][(i+2)%3]*a[2][(i+1)%3])); printf("\nDeterminant of matrix is: %d",det); } else printf("This program can't calculate determinant of matrix of order greater than 3"); }