Welcome to my blog at “We Are Knowledge”. Now I want discuss
program language C. And my tutorial is using condition with “switch”. Using
switch in program language C likely used in other program language like as :
program language C++, pasca, and other.
And this sample coding. Previously you must software for
making program language C like as
: Borland C++ or turbo C. if it is, you can
copy this and paste in your compiller.
Example 1 :
#include <stdio.h>
#include <conio.h>
int main()
{
int choice, next;
printf("============ Welcome Customer ============
\n");
printf(" This
Is Sample Program Language C \n");
printf("
Only On \n");
printf(" Only On
have-fun-and-enjoy.blogspot.com \n");
printf("
Ayam Goreng \n \n");
printf("Press Any Number And Enter To Countinue
...");
scanf("%d",&next);
clrscr();
printf("Please Your Favorite Football Club : \n");
printf("========== Football Club =========== \n");
printf("1. Chelsea Football Club \n");
printf("2. Arsenal Football Club \n");
printf("3. Man.United Football Club \n");
printf("4. Liverpool Football Club \n");
printf("5. Tottenham United Football Club \n");
printf("6. Man. City United Football Club \n \n
\n");
printf("Masukan Pilihan Menu Anda : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("\n You Are Choice CHELSEA \n");
break;
case 2:
printf("\n You Are Choice ARSENAL \n");
case 3:
printf("\n You Are Choice MAN. UNITED \n");
break;
case 4:
printf("\n You Are Choice LIVERPOOL \n");
break;
case 5:
printf("\n You Are Choice TOTTENHAM \n");
break;
case 6:
printf("\n You Are Choice MAN. CITY \n");
break;
default:
printf("\n Oh no... you are wrong !!! \n");
}
getch ();
return 0;
}
Logic :
Choice, next
>> is variable with integer data type.
Printf
>> for print in output window
Scanf
>> for input number or char in output window
%d
>> for data type integer.
Clrscr
>> for cleaning output window
Switch..
>> is conditional . to be found 2 (two) condition on
language C, IF and switch.
Ok.. just it..
I hope you understand…
See you later
No comments:
Post a Comment