Saturday, 15 March 2014

FIND VALUE OF X1 AND X2 WHICH IS SOLUTION OF LINEAR EQUATION

PROGRAM TO FIND VALUE OF X1 AND X2 WHICH IS SOLUTION OF LINEAR EQUATION

Code for PROGRAM TO FIND VALUE OF X1 AND X2 WHICH IS SOLUTION OF LINEAR EQUATION in C Programming

#include<stdio.h>
#include<conio.h>

void main()
{
    int a,b,c,d,m,n;
    float x1,x2;
    clrscr();

    printf("Enter the value of a ::  ");
    scanf("%d",&a);

    printf("Enter the value of b ::  ");
    scanf("%d",&b);

    printf("Enter the value of c ::  ");
    scanf("%d",&c);

    printf("Enter the value of d ::  ");
    scanf("%d",&d);

    printf("Enter the value of m ::  ");
    scanf("%d",&m);

    printf("Enter the value of n ::  ");
    scanf("%d",&n);

    if((a*d)-(c*b) == 0)
    printf("\nWe can't find value of x1 and x2 \n");
    else
    {
        x1 = (float)((m * d) - (b * n)) / ((a * d) - (c * b));
        printf("\nValue of x1 ::  %f ",x1);
        x2 = (float)((n * a) - (m * c)) / ((a * d) - (c * b));
        printf("\nValue of x2 ::  %f ",x2);

    }
    getch();
}
/*
    ********
     OUTPUT
    ********
    Enter the value of a ::  5
    Enter the value of b ::  2
    Enter the value of c ::  5
    Enter the value of d ::  3
    Enter the value of m ::  6
    Enter the value of n ::  7

    Value of x1 ::  0.800000
    Value of x2 ::  1.000000
*/

No comments:

Post a Comment