Soal 2
Buatlah rogram untuk menentukan nama
bulan berdasarkan angka yang di input.
Jawab
Kode Program:
#include<stdio.h>
#include<conio.h>
main()
{
int M;
printf("\n***
Menentukan Nama Bulan Berdasarkan Input Angka ***\n");
printf("
===============================================\n\n");
printf("Input
angka : ");
scanf("%i",
&M);
switch(M)
{
case
1:
printf("Bulan
Januari\n\n");
break;
case
2:
printf("Bulan
February\n\n");
break;
case
3:
printf("Bulan
March\n\n");
break;
case
4:
printf("Bulan
April\n\n");
break;
case
5:
printf("Bulan
May\n\n");
break;
case
6:
printf("Bulan
June\n\n");
break;
case
7:
printf("Bulan
July\n\n");
break;
case
8:
printf("Bulan
August\n\n");
break;
case
9:
printf("Bulan
September\n\n");
break;
case
10:
printf("Bulan
October\n\n");
break;
case
11:
printf("Bulan
November\n\n");
break;
case
12:
printf("Bulan
December\n\n");
break;
default:
printf("error");
getch();
}
}
Hasil Program:
0 comments:
Post a Comment