Bài 3.1:
#include <stdio.h>
#include <conio.h>
#include <math.h>
main()
{
float x, y, z, F ;
printf (" Nhap ba so bat ky:");
printf ("\n x="); scanf ("%f", &x);
printf (" y="); scanf ("%f", &y);
printf (" z="); scanf ("%f", &z);
F=(x+y+z)/(x*x+y*y+1) - fabs(x-z*cos(y));
printf (" Gia tri cua F=%f",F);
getch();
}
Bài 3.3:
#include <stdio.h>
#include <conio.h>
#include <math.h>
main()
{
float X,Y,F;
printf(" Nhap hai so thuc X, Y");
printf("\n X="); scanf("%f", &X);
printf(" Y="); scanf("%f", &Y);
if(X==Y)
F=7*pow(Y,6);
else
F=(pow(Y,7)-pow(X,7))/(Y-X);
printf("\n Gia tri cua F=%6.f", F);
getch();
}
Bài 3.5:
#include <stdio.h>
#include <conio.h>
main()
{
float X,Y,a,b,c;
printf(" Nhap hai so thuc X, Y:");
printf("\n X=");scanf("%f",&X);
printf(" Y=");scanf("%f",&Y);
a=X*X+Y*Y;
b=(X+Y)*(X+Y);
c=(X-Y)*(X-Y);
printf("\n X^2 + Y^2 = %10.f", a);
printf("\n (X+Y)^2 = %10.f", b);
printf("\n (X-Y)^2 = %10.f", c);
getch();
}
Bài 3.2:
#include <stdio.h>
#include <conio.h>
#define PI 3.14159
main()
{
float r,M,S;
printf (" Nhap so thuc r (r>0):");
printf ("\n r="); scanf ("%f", &r);
M=2*PI*r;
S=PI*r*r;
printf("\n Chu vi cua hinh tron M=%f", M);
printf("\n Dien tich cua hinh tron S=%f", S);
getch();
}
Bài 3.4:
#include <stdio.h>
#include <conio.h>
main()
{
int a,b,P,S;
printf("Nhap hai so nguyen a,b bat ky");
printf("\n a="); scanf("%d",&a);
printf(" b="); scanf("%d",&b);
P=2*(a+b);
S=a*b;
printf("\n Chu vi hinh chu nhat la: %d", P);
printf("\n Dien tich hinh chu nhat la: %d", S);
getch();
}
Bài 3.6:
#include <stdio.h>
#include <conio.h>
main()
{
float toan,ly,hoa;
printf("Nhap 3 diem toan, ly, hoa cua 1 hoc sinh");
printf("\n Diem Toan = ");scanf("%f",&toan);
printf("\n Diem Ly = "); scanf("%f",&ly);
printf("\n Diem Hoa = ");scanf("%f",&hoa);
printf("\n Tong diem cua hoc sinh la
%2.f",toan+ly+hoa);
printf("\n Diem trung binh cua hoc sinh la %2.1f",
(toan+ly+hoa)/3);
getch();
}
Bài 3.7:
#include <stdio.h>
#include <conio.h>
main()
{
int a,b,c;
printf(" Nhap ba so nguyen a, b, c bat ky");
printf("\n a=");scanf("%d",&a);
printf(" b=");scanf("%d",&b);
printf(" c=");scanf("%d",&c);
printf("\n Tong 3 so la: %d",a+b+c);
printf("\n Tich 3 so la: %d",a*b*c);
printf("\n Trung binh 3 so la: %d",(a+b+c)/3);
getch();
}
Bài 3.9:
#include <stdio.h>
#include <conio.h>
main()
{
char c;
printf("1.Nhap vao mot ky tu:"); scanf("%c",&c);
printf("\nMa ASCII tuong ung la: %d",c);
int s;
printf("\n\n2.Nhap vao mot so nguyen (tu 1 den
255):"); scanf("%d",&s);
printf("\nKy tu co ma ASCII tuong ung la: %c",s);
getch();
}
Bài 3.8:
#include <stdio.h>
#include <conio.h>
main()
{
int n,Sn;
printf(" Bai toan tinh tong Sn=1+2+3...+n");
printf("\n\n Nhap so nguyen n=");scanf("%d",&n);
Sn=(n+1)*n/2;
printf("\n Tong Sn=1+2+3+...+n=%d",Sn);
getch();
}