assalamualaikum wr.wb
Nim :3420210019
Prodi :Teknik Informatika
1
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza Hidayatulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
//deklarasi variable
int absen,tugas,uts,uas;
float total;
puts("program menghitung nilai mahasiswa");
puts("************************************");
printf("masukan nilai absen: ");scanf("%d",&absen);
cout<<"masukan nilai tugas: ";cin>>tugas;
printf("masukan nilai uts: ");scanf("%i",&uts);
cout<<"masukan nilai uas: ";cin>>uas;
//proses perhitungan
total = (absen*0.1)+(tugas*0.2)+(uts*0.3)+(uas*0.4);
puts("************************************");
cout<<"total adalah: "<<total<<" (bentuk tidak terformat)\n";
printf("total adalah: %.2f (bentuk yang terformat)\n",total);
puts("************************************");
//kondisi
if (total >=75 )
{ cout<<"selamat anda lulus"; }
else
{ cout<<"maaf anda tidak lulus"; }
getch();
}
2
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza Hidayatulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
int pilih;
char huruf [20];
printf ("Silakan Pilih Program [1/2]:") ; cin >> pilih;
//scanf ("%d", & pilih);
/*
There are two problems with using scanf() to get a number:
First, validation/error handling is poor.
The second problem is that of leaving characters in the buffer.
Sumber: https://faq.cprogram.com/cgi-bin/smartfaq.cgi?
*/
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 [] = "S";
char a2 [] = "s";
char b1 [] = "S";
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();
}
else
{
printf ("Maaf Pilihan Anda Salah..");
}
}
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza Hidayatulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
char gol,jab[10];
long gapok;
cout<<endl<<"data jabatan"<<endl
<<"***************************"<<endl;
cout<<"masukan golongan [1/2/3/4]: ";cin>>gol;
if(gol=='1')
{
strcpy(jab,"direktur");
gapok=7000000;
}
else if(gol=='2')
{
strcpy(jab,"manajer");
gapok=5000000;
}
else if(gol=='3')
{
strcpy(jab,"supervisor");
gapok=4000000;
}
else if(gol=='4')
{
strcpy(jab,"karyawan");
gapok=3000000;
}
else
{
printf("golongan %c tidak terdaftar.\n",gol);
strcpy(jab,"none");
gapok=0;
}
cout<<"jabatan = "<<jab<<endl;
cout<<"gaji pokok = "<<gapok<<endl;
getch();
}
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza hidaytulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
char kode,ukuran,merk[15]="none";
long harga=0;
cout<<"kode baju [1/2/3] : ";cin>>kode;
cout<<"ukuran [S/M] : ";cin>>ukuran;
if (kode=='1')
{
strcpy(merk,"SLIPKNOT");
if (ukuran=='S' || ukuran =='s') { harga=45000; } else { harga=60000; }
}
else if (kode=='2')
{
strcpy(merk,"REEBOK");
//bentuk penulisan if versi singkat
if (ukuran=='S' || ukuran == 's') harga=65000; else harga=75000;
}
else if (kode=='3')
{
strcpy(merk,"SUICIDE ANTHEM");
if (ukuran=='S' || ukuran =='s') harga=120000; else harga=125000;
}
else
{
cout<<"salah kode baju"<<endl;
}
cout<<"merk baju : "<<merk<<endl;
cout<<"harga baju : "<<harga<<endl;
getch();
}
No comments:
Post a Comment