0% found this document useful (0 votes)
4 views5 pages

NMLT Lab2

Uploaded by

qan2802
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

NMLT Lab2

Uploaded by

qan2802
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

B3:

#include <stdio.h>
#include <stdlib.h>

int main()
{
float d,r;
printf("");
scanf("%f",&d);

printf("");
scanf("%f",&r);

printf("%0.2f",d*r);
return 0;
}

-------------------------------------------------
B4:
#include <stdio.h>
#include <stdlib.h>

int main()
{
printf("Kich thuoc kieu du lieu char la: %d Byte\n",sizeof(char));
printf("Kich thuoc kieu du lieu int la: %d Byte\n",sizeof(int));
printf("Kich thuoc kieu du lieu float la: %d Byte\n",sizeof(float));
printf("Kich thuoc kieu du lieu double la: %d Byte\n",sizeof(double));
printf("Kich thuoc kieu du lieu short la: %d Byte\n",sizeof(short));
printf("Kich thuoc kieu du lieu long la: %d Byte\n",sizeof(long));

return 0;
}
--------------------------------------------------

B5:
#include <stdio.h>
#include <stdlib.h>

int main()
{
printf("char\n%ld\n",sizeof(char));
printf("int\n%ld\n",sizeof(int));
printf("float\n%ld\n",sizeof(float));
printf("double\n%ld\n",sizeof(double));
printf("short\n%ld\n",sizeof(short));
printf("long\n%ld\n",sizeof(long));
return 0;
}

B6:
#include <stdio.h>
#include <stdlib.h>

int main()
{
int V;
printf("");
scanf("%d",&V);
printf("%0.2f",V/3.6);
return 0;
}

B7:
#include <stdio.h>
#include <stdlib.h>

int main()
{
float d,h;
printf("d= ");
scanf("%f",&d);
printf("h= ");
scanf("%f",&h);
printf("%0.2f",(3.14/12)*h*pow(d,2));
return 0;
}

B8:
#include <stdio.h>
#include <stdlib.h>

int main()
{
int a,b,c;
printf("");
scanf("%d",&a);
printf("");
scanf("%d",&b);
printf("");
scanf("%d",&c);

if (a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b){


printf("right triangle");
}
else if (a==b&&a==c){
printf("equilateral triangle");
}
else if (a==b || b==c || a==c){
printf("isosceles triangle");
}
else if (a+b>c && b+c>a && a+c>b){
printf("triangle");
}
else
printf("invalid");

return 0;
}

B9:
#include <stdio.h>
#include <stdlib.h>

int main()
{
int a,b;
char c;

printf("");
scanf("%d",&a);
printf("");
scanf("%d",&b);
printf("");
scanf(" %c",&c);

if (c=='+')
printf("%d",a+b);
else if (c=='-')
printf("%d",a-b);
else if (c=='*')
printf("%d",a*b);
else if (c=='/')
printf("%d",a/b);
else if (c=='%')
printf("%d",a%b);

return 0;
}

B10:
#include <stdio.h>
#include <stdlib.h>

int main()
{
float a,b,c,t;
printf("");
scanf("%f",&a);
printf("");
scanf("%f",&b);
printf("");
scanf("%f",&c);

t = (a+b+c)/3;
printf("%0.2f \n",t);

if (t>=9)
printf("xuat sac");
else if (t>=8 && t<=9)
printf("gioi");
else if (t>=7 && t<=8)
printf("Kha");
else if (t>=5 && t<=7)
printf("trung binh");
else
printf("yeu");

return 0;
}

B11:
#include <stdio.h>

int main()
{
float a,t ;
printf("%s","");
scanf("%f",&a);
if (a<=2) {
printf("20000");
}
else if (a>=2 && a<=30) {
t = 20000 + (a-2)*9000;
printf("%.0f",t);
}
else if (a>=30) {
t = 20000 + 9000*28 + (a-30)*7000;
printf("%.0f",t);
}

return 0;
}

B12:
#include <stdio.h>

int main()
{
float xA, yA, xB, yB, AB, OB, OA, max ;
printf("");
scanf("%f",&xA);
printf("");
scanf("%f",&yA);
printf("");
scanf("%f",&xB);
printf("");
scanf("%f",&yB);

if ((xA/yA)==(xB/yB))
printf("1\n");
else
printf("0\n");

//AB
AB = (xB-xA)*(xB-xA) + (yB-yA)*(yB-yA);
//OB
OB = xB*xB + yB*yB;
//OA
OA = xA*xA + yA*yA;

if (AB>OB) {
max = AB;
if (AB>OA)
max = AB;
else
max = OA;
}
else {
max = OB;
if (OB>OA)
max = OB;
else
max = OA;
}
printf("%0.2f",max);

return 0;
}

BT them:
#include <stdio.h>
#include <stdlib.h>

int main()
{
int i;
for(i=1;i<=100;i++)
if (i%3==0 && i%5==0)
printf("FizzBuzz\n");
else if (i%3==0)
printf("Fizz\n");
else if (i%5==0)
printf("Buzz\n");
else
printf("%d\n",i);

return 0;
}

You might also like