ISLAM CORNER | HANDPHONE | HACKING | BLOGGING TIPS | INTERNET | WINDOWS TRICK | SEO | SOFTWARE | VIRUS | ISENG |

Jumat, 12 November 2010

PRAKTIKUM 3

PRAKTIKUM 3

1).
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{
int a=0,b=0,c;
cout<<"masukkan total pembelanjaan Rp";
cin>>a;
if (a>100000)
b=0.10*a;
cout<<"vesar potongan dari pembelanjaan anda Rp"<<b;
c=a-b;
cout<<"\n jumlah yang harus dibayar Rp";
cout<<c;
getch();
}

2).
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <math.h>
main()
{
float a,b,c;
double D;
int x1,x2;
cout<<"program persamaan kuadrat\n\a\n";
cout<<"masukkan nilai a:";cin>>a;
cout<<"masukkan nilai b:";cin>>b;
cout<<"masukkan nilai c:";cin>>c;
d = b*b-4*a*c;
cout<<"\n nilai deskriminan:"<<d;
if (d==0)
{ x1=x2-b/2*a;
cout<<"\n nilai akar-akar persamaan tersebut: \n;
cout<<"x1="<<x1;
cout<<"\tx2="<<x2;
if (d>0)
{ x1=(-b+sqrt (d)/2*a;
x2=(-b-sqrt (d)/2*a;
cout<<"nilai akar-akar persamaantersebut :\n;
cout<<"x1="<<x1;
cout<<"\tx2="<<x2;
if (d>0)
{ x1= -b/2*a+(sqrt (d)/2*a);
x2= -b/2*a-(sqrt (d)/2*a);
cout<<"nilai akar-akar persamaantersebut :\n;
cout<<"x1="<<x1;
cout<<"\tx2="<<x2;
getch();
}

Tidak ada komentar:

Posting Komentar

Komentar