Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

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

Posted By: Toni Mitchell     Category: C Programming     Views: 5508

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
*/
  
Share: 



Toni Mitchell
Toni Mitchell author of PROGRAM TO FIND VALUE OF X1 AND X2 WHICH IS SOLUTION OF LINEAR EQUATION is from St Louis, United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!