Basit C kodundaki hata nedir?

AwieNN

Picopat
Katılım
10 Ocak 2022
Mesajlar
5
Daha fazla  
Cinsiyet
Erkek
#include <stdio.h>

int main(void)
{
double x1;
double x2;
double a;
double b;
double c;
double d;

printf("Please enter an integer value a:");
a = getchar();
printf("Please enter an integer value b:");
b = getchar();
printf("Please enter an integer value c:");
c = getchar();

if(a==0)
{
if(b==0)
{
if(c==0){
printf("every number is solution");
}
else{//c != 0
printf("no solution");
}
}
else//b != 0
{
x1 = -c/b;
printf("x1 is ");
printf(x1);
}
}else{//a != 0
d = ((b*b)-4*a*c)/4*a*a;
if(d<0){
x1 = -b/(2*a) +(i)*sqrt(d);
printf(x1 + "\n');
x2 = -b/(2*a) -i*sqrt(d);
printf(x2) ;
}
else if(d==0){
x1 = -b/2*a;
printf("x1 =" + x1);
}
else{//d>0
x1 = (-b/(2*a))+sqrt(d);
x2 = (-b/(2*a))-sqrt(d);
printf("x1 = " x1 '\n');
printf("x2 = "x2");
}
}
}

return 0;
}
 
[CODE lang="c" title="Template"]#include <stdio.h>

int main(void)
{
double x1;
double x2;
double a;
double b;
double c;
double d;

printf("Please enter an integer value a:");
scanf("%lf",&a);
printf("Please enter an integer value b:");
scanf("%lf",&b);
printf("Please enter an integer value c:");
scanf("%lf",&c);

if(a==0)
{
if(b==0)
{
if(c==0){
printf("every number is solution");
}
else{//c != 0
printf("no solution");
}
}
else//b != 0
{
double x1 = -c/b;
printf("x1 is ");
printf("%lf",x1);
}
}else{//a != 0
d = ((b*b)-4*a*c)/4*a*a;
if(d<0)
{
x1 = -b / (2*a) + sqrt(d);
printf("%lf \n",x1);
x2 = -b/(2*a) + sqrt(d);
printf("%lf \n",x2);
}
else if(d==0){
x1 = -b/2*a;
printf("%x1 = lf \n",x1);
}
else{//d>0
x1 = (-b/(2*a))+sqrt(d);
x2 = (-b/(2*a))-sqrt(d);
printf("%x1 = lf \n",x1);
printf("%x2 = lf \n",x2);
}
}
}
[/CODE]

Printf ve scanf fonksiyonlarına daha çok çalışmanız lazım.
 
Çok teşekkür ederim fakat [Warning] incompatible implicit declaration of built-in function 'sqrt' uyarısı aldım ? ama kod çalıştı gibi oldu bi sorun var mı ?
 

Technopat Haberler

Yeni konular

Geri
Yukarı