Program bahasa C
#include <stdio.h>
#include <stdlib.h>
// fungsi function//
float luas_sg3(float a, float t);
float kel_sg3(float a, float s1, float s2);
int main ()
{
int x;
float a, t, s1, s2, kel;
float luas;
printf("ketik alas dan tinggi : ");
scanf("%f %f",&a,&t);
printf("ketik sisi miring : ");
scanf("%f %f",&s1,&s2);
printf("menu\n 1. luas segitiga\n 2. keliling segitiga\n");
printf("ketik menu = ");
scanf("%d",&x);
if(x==1)
{
luas=luas_sg3(a,t);
printf("luas segitiga = %f\n\n\n",luas);
}
else if (x==2)
{
kel=kel_sg3(a, s1, s2);
printf("keliling segitiga = %f\n\n\n",kel);
}
else
{
printf("menu salah");
}
return main();
return 0;
}
float luas_sg3(float a, float t)
{
return (a*t)/2;
}
float kel_sg3(float a, float s1, float s2)
{
return a+s1+s2;
}
Comments
Post a Comment