Tuesday 18 November 2014

Contoh Program if else if #1

Program If else if sederhana, berikut kode programnya:

  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5.    clrscr();
  6.    int pilih;  //deklarasi variabel dengan tipe data int (bilangan bulat)
  7.    cout<<"Masukkan Pilihan = ";
  8.    cin>>pilih;
  9.    if (pilih==1)
  10.       cout<<"Rekayasa Perangkat Lunak";
  11.    else if (pilih==2)
  12.       cout<<"Multimedia";
  13.    else if (pilih==3)
  14.       cout<<"Teknik Komputer dan Jaringan";
  15.    else
  16.       cout<<"Salah masukkan jurusan";
  17.    getch();
  18. }



Output:

No comments:

Post a Comment