#include <stdio.h>
#DEFINE suntetagmenes 3

double eswterikoginomeno(double dianusmata[][suntetagmenes])
{
    int j;
    double eswteriko=0;
    for (j=0;j<suntetagmenes;j++)
    {
        eswteriko+=dianusmata[0][j]*dianusmata[1][j];
    }
    return(eswteriko);
}

double e3wterikoginomeno(double dianusmata[][suntetagmenes], int i)
{
    double e3wteriko;
    if (i==0)
    {
        e3wteriko=dianusmata[0][1]*dianusmata[1][2]-dianusmata[0][2]*dianusmata[1][1];
    }
    else if (i==1)
    {
        e3wteriko=dianusmata[0][2]*dianusmata[1][0]-dianusmata[0][0]*dianusmata[1][2];
    }
    else
    {
        e3wteriko=dianusmata[0][0]*dianusmata[1][1]-dianusmata[0][1]*dianusmata[1][0];
    }
    return(e3wteriko);
}

int main()
{
    char x='m';
    int count=0, i, j, pra3i, k=0;
    double dianusmata[2][suntetagmenes]={0}, esw_gin, e3w_gin[suntetagmenes]={0};
    while (x=='m')
    {
        for (i=0;i<=1;i++)
        {
            printf("Dwste 3 suntetagmenes gia to dianusma: ");
            for (j=0;j<suntetagmenes;j++)
            {
                scanf("%lf",dianusmata[i][j]);
            }
        }
        printf("Epile3te:\n1.Ypologismos eswterikou ginomenou\n2.Ypologismos e3wterikou ginomenou\n");
        scanf("%d",&pra3i);
        while ((pra3i!=1)&&(pra3i!=2))
        {
            if (count==1)
            {
                exit(-1);
            }
            printf("Dwsate la8os eisodo!\nEpile3te:\n1.Ypologismos eswterikou ginomenou\n2.Ypologismos e3wterikou ginomenou\n");
            scanf("%d",&pra3i);
            count=1;
        }
        esw_gin=eswterikoginomeno(dianusmata);
        printf("To eswteriko ginomeno twn dianusmatwn pou dwsate einai %lf.",esw_gin);
        if (esw_gin==0)
        {
            printf("Diladi ta dianusmata einai ka8eta meta3u tous.");
        }
        for (i=0;i<suntetagmenes;i++)
        {
            e3w_gin[i]=e3wterikoginomeno(dianusmata,i);
        }
        printf("To e3wteriko ginomeno twn dianusmatwn pou dwsate einai %lf.",e3w_gin[suntetagmenes]);
        for (i=0;i<suntetagmenes;i++)
        {
            if (e3w_gin[i]==0)
            {
                k++;
            }
        }
        if (k==3)
        {
            printf("Diladi ta dianusmata pou dwsate einai parallila meta3u tous.");
        }
        printf("Pliktrologiste m gia na epistrepsete sto menu i e gia na kanete exit!");
        scanf("%c",&x);
        while ((x!='m')&&(x!='e'))
        {
            printf("Dwsate la8os eisodo!\nPliktrologiste m gia na epistrepsete sto menu i e gia na kanete exit!");
            scanf("%c",&x);
        }
    }
    return(0);
}

SEGMENTATION FAULT :( I DON'T KNOW WHAT TO DO... HELP ME PLEASE!

A segmentation fault in this case probably means you accessed one of the arrays out of bounds. Start up a debugger and keep a watch on your indices.

A segmentation fault in this case probably means you accessed one of the arrays out of bounds. Start up a debugger and keep a watch on your indices.

that's what I'm trying to do but no luck so far... :/

>scanf("%lf",dianusmata[j]);
You forgot the address-of operator here:

scanf("%lf", &dianusmata[i][j]);

>scanf("%lf",dianusmata[j]);
You forgot the address-of operator here:

scanf("%lf", &dianusmata[i][j]);

thank you sooo much! now I see I have done something else wrong... :P

I fixed it! it's working now! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.