Bài 1:
Viết chương trình cho phép người dùng nhập vào một số thực x từ bàn phím, sau đó:
a.     In ra giá trị x2 và căn bậc 2 của x,
b.     Tính giá trị của hàm : 


c.      Tính giá trị của hàm f(x) = (e|x| + log5x)/(3x +1).
d.     Viết chương trình cho phép người dùng nhập vào một giá trị x từ bàn phím, sau đó tính các giá trị sinx, cosx, tgx, arcsinx, arccosx, arctgx.




//Câu a:
#include<stdio.h>
#include<math.h>

int main(void)
{
float x;

printf("Nhap vao so thuc x: ");scanf("%f",&x);
printf("%f^2 = %.2f\n",x,x*x);

if(x<0) printf("%f khong co can bac 2!\n",x);
else
printf("Can bac 2 cua %f la: %.2f\n",x,sqrt(x));

return 0;
}
//Câu b:
#include <stdio.h>
#include <math.h>

int main(void)
{
float x;
printf("Nhap vao so thuc x: ");
scanf("%f",&x);

if(x<0)
printf("f(%f) = %.2f",x,fabs(x));
else if(x>0)
printf("f(%f) = %.2f",x,log(x));
else
printf("f(%f) = 0",x);

return 0;
}
//Câu c:
#include <stdio.h>
#include <math.h>

int main(void)
{
float x,fx;

printf("Nhap vao gia tri cua x: ");scanf("%f",&x);
fx = (exp(fabs(x)) + log(x)/log(5))/(pow(3,x)+1);
printf("f(%.2f) = %.2f",x,fx);

return 0;
}
//Câu d:
#include <stdio.h>
#include <math.h>

int main(void)
{
float x;

printf("Nhap vao gia tri x: ");scanf("%f",&x);

printf("Sin(%.2f) = %.2f,cos(%.2f) = %.2f,tan(%.2f) = %.2f\nArcsinx(%.2f) = %.2f,arccosx(%.2f) = %.2f,arctgx(%.2f) = %.2f\n",
x,sin(x),x,cos(x),x,tan(x),x,asin(x),x,acos(x),x,atan(x));

return 0;
}
Coding: Hải Dớ