#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int n;
cout << " ---Konversi Bilangan Menjadi Kode ASCII--- " << endl;
cout << " __________________________________________ " << endl;
cout << " Masukan Bilangan (maks. 255) : "; cin >> n;
cout << " ASCII dari bilangan tersebut "<< n <<" adalah : "<<(char)n<<endl;
return 0;
}
Kamis, 07 April 2016
DIKTAT BAB 4 NO 5
#include <iostream>
#include <conio.h>
using namespace std;
int main(){
int tahun, bulan,bil;
cout << " Masukkan Tahun : "; cin >> tahun;
cout << " Masukkan Bulan ke : "; cin >> bulan;
switch (bulan)
{
case 2:
if ((tahun%100==0)||(tahun%100!=0)&&(tahun%400==0))
{
for(int i=1; i<=29; i++)
{
cout<<i<<" ";
}
}
else
{
for(int i=1; i<=28; i++)
{
cout<<i<<" ";
}
}
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
{
for(int i=1; i<=31; i++)
{
cout<<i<<" ";
}
}
break;
case 4:
case 6:
case 9:
case 11:
{
for(int i=1; i<=30; i++)
{
cout<<i<<" ";
}
}
break;
default:
cout<<"salah kode bulan\n";
}
getch();
}
#include <conio.h>
using namespace std;
int main(){
int tahun, bulan,bil;
cout << " Masukkan Tahun : "; cin >> tahun;
cout << " Masukkan Bulan ke : "; cin >> bulan;
switch (bulan)
{
case 2:
if ((tahun%100==0)||(tahun%100!=0)&&(tahun%400==0))
{
for(int i=1; i<=29; i++)
{
cout<<i<<" ";
}
}
else
{
for(int i=1; i<=28; i++)
{
cout<<i<<" ";
}
}
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
{
for(int i=1; i<=31; i++)
{
cout<<i<<" ";
}
}
break;
case 4:
case 6:
case 9:
case 11:
{
for(int i=1; i<=30; i++)
{
cout<<i<<" ";
}
}
break;
default:
cout<<"salah kode bulan\n";
}
getch();
}
Langganan:
Postingan (Atom)