Assalamualaikum wr.wb
Nim : 3420227001
Prodi: Teknik Informatika
Contoh 1
Lampiran Contoh 1 sofware Borland C++
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
void main() {
//Nama : Muhamad Syarif Ramadhan
//Nim : 3420227001
int absen,tugas,uts,uas;
float total;
puts("Program Menghitung Nilai Mahasiswa");
puts("++++++++++++++++++++++++++++++++++");
printf("Masukan Nilai Absen:");scanf("%d",&absen);
printf("Masukan Nilai Tugas:");scanf("%d",&tugas);
printf("Masukan Nilai UTS:");scanf("%i",&uts);
printf("Masukan NIlai UAS:");scanf("%I",&uas);
total=(absen*0.1)+(tugas*0.2)+(uts*0.3)+(uas*0.4);
puts("++++++++++++++++++++++++++++++++++");
printf("Total Adalah:%.2f(Bentuk Tidak Terformat)\n",total);
printf("Total Adalah:%.2f(Bentuk Yang Terhormat)\n",total);
puts("++++++++++++++++++++++++++++++++++");
if (total>=75)
{cout<<"Selamat Kamu Lulus.";}
else
{cout<<"Maaf Kamu Tidak Lulus.";}
getch();
}
Contoh 2
Lampiran Contoh 2 sofware Borland C++
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
void main(){
// Nama : Muhamad Syarif Ramadhan
// Nim : 3420227001
int pilih;
char huruf [20];
printf ("Silakan Pilih Program [1/2]:") ; cin >> pilih;
if (pilih == 1){
clrscr();
puts ("+++++++++++++++++++++++++");
puts ("\Contoh Program Strlen");
puts ("+++++++++++++++++++++++++");
cout <<"Masukan Sembarang Kata = "; gets (huruf);
cout <<"Panjang Kata Yang Diinput = "<<strlen(huruf);
getch() ;
}
else if (pilih == 2){
clrscr();
puts ("+++++++++++++++++++++++++");
puts ("\Contoh Program Strcmp");
puts ("+++++++++++++++++++++++++");
char a1 [] = "Z";
char a2 [] = "z";
char b1 [] = "Z";
cout <<"Hasil Perbandingan "<<a1<<" dan "<<a2<< "->";
cout <<strcmp (a1,a2) <<endl;
cout <<"Hasil Perbandingan "<<a2<<" dan "<<a1<< "->";
cout <<strcmp (a2,a1) <<endl;
cout <<"Hasil Perbandingan "<<a1<<" dan "<<b1<< "->";
cout <<strcmp (a1,b1) <<endl;
getch();
}
}
Contoh 3
Lampiran Contoh 3 sofware Borland C++
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
void main(){
// Nama : Muhamad Syarif Ramadhan
// Nim : 3420227001
char gol,jab[10];
long gapok;
cout<<endl<<"Data Jabatan"<<endl
<<"++++++++++++++++++++++++++"<<endl;
cout<<"Masukan Golongan [1/2]: ";cin>>gol;
if(gol=='1'){
strcpy(jab,"Manajer");
gapok=6000000;
}
else if(gol=='2'){
strcpy(jab,"Karyawan");
gapok=4500000;
}
else{
printf("Golongan %c tidak terdaftar.\n",gol);
strcpy(jab,"None");
gapok=0;
}
cout<<"Jabatan = "<<jab<<endl;
cout<<"Gaji Pokok = "<<gapok<<endl;
getch();
}
Contoh 4
Lampiran Contoh 4 sofware Borland C++
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
void main(){
// Nama : Muhamad Syarif Ramadhan
// Nim : 3420227001
char kode,ukuran,merk[15]="None";
long harga=0;
cout<<"Kode Baju [1/2] : ";cin>>kode;
cout<<"Ukuran [S/M] : ";cin>>ukuran;
if (kode=='1'){
strcpy(merk, "Converse");
if (ukuran=='S' || ukuran == 's') {harga=200000;} else {harga=210000;}
}
else if (kode=='2'){
strcpy(merk,"Nike");
//Bentuk penulisan if versi singkat
if (ukuran=='S' || ukuran == 's') harga=600000; else harga=610000;
}
else{
cout<<"Salah Kode Baju"<<endl;
}
cout<<"Merk Baju :"<<merk<<endl;
cout<<"Harga Baju :"<<harga<<endl;
getch();
}
Sekian dan Terimakasih
Wassalamualaikum wr.wb
No comments:
Post a Comment