Selasa, 06 Mei 2014

Tugas 2 algoritma

Latihan 1
#include <iostream.h> #include <conio.h>
void main()
{ int usia;
  cout<<"Berapa Usia Anda : ";
  cin>usia;
  if (usia<17)
            cout<<"Anda belum dewasa"<<endl;
  else
            cout<<"Anda dewasa"<<endl; }


Latihan 2
#include<iostream.h> #include<conio.h>
void main()
{ int bil;
  cout<<"Masukkan sebuah bilangan : ";
  cin>>bil;
  if (bil % 2==0)
            cout<<"Ini Adalah Bilangan Genap"<<endl;
  else
            cout<<"Ini Bilngan Ganjil"<<endl; }

Latihan 3
#include <iostream.h>  #include <conio.h>
void main()
{int a;
  clrscr();
  cout<<"Masukkan Kode Jabatan ";
  cin>>a;
  if (a==1)
              { cout<<"Golongan anda I"<<endl;
                         cout<<"Gaji anda Rp. 1000"<<endl;
                         cout<<"Anda orang miskin";}
  else
              { cout<<"Golongan anda II"<<endl;
                         cout<<"Gaji anda Rp. 2000"<<endl;
                         cout<<"Anda orang kaya";}}

Tidak ada komentar:

Posting Komentar