Sign in to follow this  
Cornel Iulian

[C] Rezolvarea ecuatiei de gradul 1 [Limbaj C]

1 post in this topic

Cerinta: Sa se scrie un program C pentru rezolvarea ecuatiei de gradul 1.

#include <stdio.h>
#include <stdlib.h>

int main()
{
  float a,b,x;
  printf("Introduceti valorile lui a si b: ");
  if(scanf("%f%f",&a,&b)!=2)
   {
     printf("Date eronate!");
     exit(1);
   }
  if(a!=0)
  	{
        x=-b/a;
        printf("Valoarea lui x este: %g",x);
	}   
  else
       if(b!=0)     
 			printf("Ecuatie imposibila.");
        else 
		   	printf("Ecuatie nedeterminata.");
	return 0;
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this