[ create a new paste ] login | about

Link: http://codepad.org/IWaP5vb1    [ raw code | output | fork | 3 comments ]

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

float Tinh(float x)
{
	float ketqua;
	if(x >= 5)
		ketqua = 2 * x * x + 5 * x + 9;
	else
		ketqua = -2 * x * x + 4 * x - 9;
	return ketqua;

}
int main()
{
	float x;
	printf("\nNhap x: ");
	scanf("%f", &x);
	float ketqua = Tinh(x);
	printf("\nKet qua = %f", ketqua);

	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(){
int x;
cout <<"Enter x= ";
cin >>x;
int temp=0;
if ( x>= 5){
temp=2*pow(x,2)+5*x+9;
cout<<temp;
return 0;
}
else if ( x < 5){
temp=pow(-2*x,2)+4*x-9;
cout<<temp;
return 0;
}
}
reply
posted by yonnon on Jul 12
Sau này có thể để cái đề dễ nhìn xíu được không mấy anh?
reply
posted by cuong.luucb8921 on Sep 1
#include<stdio.h>

int main(){
float f;
float x;

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

if(x>=5)
{
f = 2*x*x + 5*x + 9;
}
else
{
f = -2*x*x + 4 *x - 9;
}

printf("f(%f) = %f",x,f);
return 0;
}
reply