[ create a new paste ] login | about

Link: http://codepad.org/Tpd4Bydg    [ raw code | output | fork | 2 comments ]

C, pasted on Sep 6:
#include<stdio.h>
#include<conio.h>

int main()
{
	float a, b;
	float x;
	printf("\nNhap a: ");
	scanf("%f", &a);
	printf("\nNhap b: ");
	scanf("%f", &b);

	if(a == 0)
	{
		if(b == 0)
			printf("\nPT co vo so nghiem");
		else
			printf("\nPT vo nghiem");
	}
	else
	{
		x = -b / a;
	printf("\nPT co 1 nghiem la %f", x);
	}
	getch();
	return 0;

}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by yonnon on Jul 12
#include<bits/stdc++.h>

using namespace std;
int main(){
float a,b;
cout<<"a= ";
cin >> a;
cout << "b= ";
cin >> b;
float x=0;
if( a==0 && b==0){
cout <<"Many solution ";
return 0;
}
x=-b/a;
cout << "Solution: "<<x<<
endl;
cin.ignore();
return 0;
}
reply
posted by cuong.luucb8921 on Sep 1
#include<stdio.h>

int main(){
float a;
float b;

printf("Nhap vao a:\n");
scanf("%f", &a);

printf("Nhap vao b:\n");
scanf("%f", &b);

printf("Phuong trinh co dang: %f*x + %f = 0\n",a,b);

if(a==0)
{
if(b==0)
{
printf("Phuong trinh co vo so nghiem");
}
else
{
printf("Phuong trinh vo nghiem");
}
}

else
{
float x= -b/a;
printf("Phuong trinh co nghiem duy nhat: x = %f",x);
}
return 0;
}
reply