.

15 views
Skip to first unread message

Пафката Дешев

unread,
Jun 24, 2013, 6:00:22 PM6/24/13
to prog1...@googlegroups.com
#include <stdio.h>
#include <math.h>

int main()
{
 double a, b, c, x1, x2, D;
 char choice = 'a';
 while( choice != 'e' )
 {
  printf( "a: " );
  scanf( "%lf", &a );
  printf( "b: " );
  scanf( "%lf", &b );
  printf( "c: " );
  scanf( "%lf", &c );

  D = b*b - 4*a*c;

  if( D < 0 )
   printf( "Nqma realni koreni.\n" );

  else if( D == 0 )
  { 
   x1 = (-b) / (2*a);
   printf( "D: %lf\n", D );
   printf( "Dva ednakvi realni korena: %lf\n", x1 );
  }

  else
  { 
   x1 = (-b + sqrt(d)) / (2*a);
   x2 = (-b - sqrt(d)) / (2*a);
   printf( "D: %lf\n", D );
   printf( "x1: %lf, x2: %lf\n", x1, x2 );
  }
  printf( "exit? y/n " );
  scanf( "%c", &choice );
  getchar( );
  if( choice == 'y' )
   break;
 }
 return 0;
}
Reply all
Reply to author
Forward
0 new messages