Fungsi : perbandingan nilai terbesar&kecil,permutasi&kombinasi, pertambahan nilai,<ABC derajat

  1. Tulis listing Program dari semua percobaan yang dilakukan.
  • Percobaan 1

#include <stdio.h>

int banding(int,int);

main()

{

int x,y, z;

printf(“MENENTUKAN BILANGAN TERBESAR\n:”);

printf(“masukkan nilai x :”);

scanf(“%d”,&x);

printf(“masukkan nilai y : “);

scanf(“%d”,&y);

z=banding (x,y);

printf(“nilai terbesar %d\n”,z);

}

int banding (int x,int y)

{

if(x>y)

return (x);

else

return (y);

}

  • Percobaan 2

#include <stdio.h>

int permutasi (int,int);

int kombinasi (int,int);

main()

{

int n,a,r,b;

printf(“PERMUTASI DAN KOMBINASI\n “);

printf(“masukkan nilai n:”);

scanf(“%d”,&n);

printf(“masukkan nilai r:”);

scanf(“%d”,&r);

a=permutasi (n,r);

b=kombinasi (a,r);

printf(“permutasiP(%d,%d)=%d\n”,n,r,a);

printf(“kombinasiC(%d,%d)=%d\n”,n,r,b);

}

int permutasi(int x, int y)

{

int i=1, total =1, sum=1,z , hasil;

z=x-y ;

for (i;i<=x;i++)

total =total*i;

for (i;i<=z;i++)

sum=sum*i;

hasil= total/sum;

return (hasil);

}

int kombinasi (int x , int y)

{

int i=1, total=1;

for(i;i<=y;i++)

total=total*i;

return(x/total);

}

  • Percobaan 3

#include <stdio.h>

void ubah (int *px, int *py);

main()

{

int x,y;

printf(“masukkan bilangan x:”);

scanf(“%d”,&x);

printf(“masukkan bilangan y:”);

scanf(“%d”,&y);

ubah (&x,&y);

}

void ubah (int *px,int *py)

{

*px= *px+ 2;

*py= *py+ 2;

printf(“bilangan 1 setelah ditambah  : %d\n”,*px);

printf(“bilangan 2 setelah ditambah : %d\n”,*py);

}

  • Percobaan 4

#include <stdio.h>

#include <math.h>

float radian(float,float);

main()

{

float d,h,ab;

printf(“Masukkan <BAC derajat : “);

scanf(“%g”, &d);

printf(“Masukkan panjang ab : “);

scanf(“%g”, &ab);

h=radian(d,ab);

printf(“panjang bc : %g\n”,h );

}

float radian(float d,float ab)

{

float pi=3.14f, rad,bc;

rad=d/180*pi;

bc=tan(rad)*ab;

return bc;

}

 

 

@copyright tresnamaulanaf

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s