1. Sorting of three integers
หมายเหตุ ใน Flowchart ใช้สัญญลักษณ์ output ผิด
//Sukphanat Phongsanam 5613404276 sec.3
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n1,n2,n3;
printf("Please enter three number\n");
scanf("%d%d%d",&n1,&n2,&n3);
if (n1>n2)
{
if (n1>n3)
{
if (n2>n3)
{
printf("%d %d %d",n1,n2,n3);
}
else
printf("%d %d %d",n1,n3,n2);
}
else
{
printf("%d %d %d",n3,n1,n2);
}
}
else
{
if (n2>n3)
{
if (n1>n3)
{
printf("%d %d %d",n2,n1,n3);
}
else
{
printf("%d %d %d",n2,n3,n1);
}
}
else
{
printf("%d %d %d",n3,n2,n1);
}
}
return 0;
}
2. Menu of coffees.
หมายเหตุ ชื่อตัวแปรควรเป็น choice และเมนูควรเป็น character ใน flowchart
#include <stdio.h>
#include <stdlib.h>
//Nitisak kingboo 5713402639
int main()
{
char choice;
printf("Welcome to my coffee!\n");
printf("1.CAPPUCHINO\n2.LATTE\n3.MOCHA\n4.ESPRESSO\n");
printf("Please pick your choice:");
choice=getche();
switch (choice)
{
case '1':
printf("\nis your CAPPUCHINO.\n");
break;
case '2':
printf("\nis your LATTE.\n");
break;
case '3':
printf("\n is your MOCHA.\n");
break;
case '4':
printf("\n is your ESPRESSO.\n");
break;
default:
printf("\nInvalid choice!\n");
}
return 0;
}
3. ดูดวง
หมายเหตุ อาจจะใช้ character แทนแต่ละวัน ในกล่อง input/output ต้องระบุว่าเป็น output หรือ input
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
char choice;
printf("Welcome to my program Daily horoscope!\n");
printf("\nPlease pick your choice:\n");
printf("\n1.Sunday\n2.Monday\n3.Tuesday\n4.Wednesday\n5.Thursday\n6.Friday\n7.Saturday\n");
printf("\nPlease pick your choice:");
choice=getche();
switch (choice)
{
case '1':
printf("\nThe obstacles have occurred prior to major changes.\n Having a good mentor You can direct your destiny to success.\n");
break;
case '2':
printf("\nTo find a place that is not clear .\n Or imprecise some The need to adjust Or to experience the unexpected.\n");
break;
case '3':
printf("\nThis imagery And intentions on the issue of jobs require ingenuity.\n And beware of the side in which to invest anything into it.\n");
break;
case '4':
printf("\nThe brilliance of the plan .\n Learning the tricks that have to do what you love to do, lead to success . And to resolve.\n");
break;
case '5':
printf("\nThe catch is money to do it all .\n Progress With the success of the work is satisfactory.\n");
break;
case '6':
printf("\nAcropolis is a great help .\n Or team work effectively.\n Working together effectively.\n");
break;
case '7':
printf("\nWhat about the administrative side of the work is planned.\n And modify And to meet the people increased.\n");
break;
default:
printf("\nInvalid choice, bye!\n");
}
return 0;
4. Leap years (ปีอธิกสุรทิน)
หมายเหตุ ในกล่อง input/output ต้องระบุว่าเป็น output หรือ input
// Chanathip Nasok
// 5613400885 Sec.3
// Group 8
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int year;
printf("Please enter year(AD)\n");
scanf("%d", &year);
if (year%400==0)
printf("leap year\n");
else if (year%100==0)
printf("not leap year\n");
else if (year%4==0)
printf("leap year\n");
else printf("not leap year\n");
return 0;
}