15
90, 3 - 1V11 7 )Vin MA 1 1 6 1] 1 C 141.811tWif KI,tc;)K9nmpi rimff vitatinwilmn: nnRniAnh - nirl 2 : 4 3.1m - 181.12557 544/Il: 241-101 /242-101 6 11'a r rirl: Introduction to Computer Programming r1' v 2556 LqWW4z11: 13.30 - 16.30 Id. cCiralA'au: Robot, S817, A401, A400, R200, S102, S103 v(inlun-n - liocu MY1921111. 1111 no . 7v /11,1471 TA 1197 11W,.:`r1/115 - 13111.1 1 nnnn15 -Finwi r611471t1W(X"gtintraliZAWLI 1,1,R4i1161=1111ct'l i lAT11,9riOldila.11 1 1TilW4VLI LInnnn co1auwE wt:14 1/11t,RiElALMIL° 11'lci/iMMIJ anonw-dlni 3 63311,11 (180 1,141) ilraolcDuri 15 1/1`,I1 J'93.1120 Ltlum?,, -LLuuLT 5 ni 40 % FilmoiniTtiln-r141,3:Joon riccf,F1'arilgUltailf1.4e101 (&-w1 - 1?111,uuiw. - , 6 h11)1 6 1i / nvi , An Liimathan= Liino 7 1"16 6 iii4 4ELeilflUirl1MVI141Jsarmi L1,2:5vi L n th wfl,leh cif uci 9, lInn 9 N1pLilnufriwalivva 112 cl 1t11,A0k11,1112' ' \rnAVI 9, TilcunrimIcu inficifi 4 (30) ulfr'ii 1 (30) u 2 (21) Ira 3 (39) TrJ U 120 1,1 -5111.-ad Li ciriVact4n17A'atl Ivibluvrwm_171ipmiconnTruanlAinn-inniuctnAunmnnTPrn_In

MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

90,

3-1V117)Vin MA1161] 1C141.811tWif

KI,tc;)K9nmpirimff

vitatinwilmn: nnRniAnh-nirl 2

: 4 3.1m-181.12557

544/Il: 241-101 /242-101

611'a rrirl: Introduction to Computer Programming

r1'v 2556

LqWW4z11: 13.30 - 16.30 Id.

cCiralA'au: Robot, S817, A401, A400, R200,

S102, S103

v(inlun-n-liocu MY1921111.1111 no .7v /11,1471 TA 1197 11W,.:`r1/115-13111.1 1 nnnn15-Finwi

r611471t1W(X"gtintraliZAWLI 1,1,R4i1161=1111ct'lilAT11,9riOldila.1111TilW4VLI

LInnnn co1auwE

wt:14 1/11t,RiElALMIL°11'lci/iMMIJ anonw-dlni

3 63311,11 (180 1,141)

ilraolcDuri 15 1/1`,I1 J'93.1120 Ltlum?,,-LLuuLT5ni 40 %

FilmoiniTtiln-r141,3:Joon riccf,F1'arilgUltailf1.4e101

(&-w1-1?111,uuiw.-,6h11)161i/nvi,An Liimathan= Liino71"166iii4 4ELeilflUirl1MVI141Jsarmi

L1,2:5viLn thwfl,lehcifuci 9,

lInn9N1pLilnufriwalivva 112 cl 1t11,A0k11,1112''\rnAVI

9, TilcunrimIcu

inficifi 4 (30)

ulfr'ii 1 (30) u 2 (21) Ira 3 (39) TrJ U 120 1,1-5111.-ad

Li — ciriVact4n17A'atl Ivibluvrwm_171ipmiconnTruanlAinn-inniuctnAunmnnTPrn_In

Sunton
Typewriter
CoE ติวเตอร์
Sunton
Typewriter
Facebook : TTon Ton เพจ : พี่ทรติวเตอร์
Sunton
Typewriter
พี่ทรติวเตอร์
Page 2: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

UYIY1 1 Aca3Aq6F1ia51411,1y114 (30 ntL11.41.4)

ATLIci 1 64 'anglwalAtcri7;101qYhiAl'alvilnu X Mltin5st',2114gwvau (15 Prct,'66M4)

1. 691almLThiLvip-INwrilInmaArApfldniAlnu

a) /-13..1-1J‘n11-1.1"(q,01Ltlij153.4-11_1=qedli,Snh-vg,'P-inl-iriV1,Avin3.1A(Dln-12

b) zi3-Ann]Lrniiirnl.,1,1MhAnurnainn

c) mnsnii-Onzu'rm,i,vin1-11,AininlvJmLir)

d)

e) zn1.4-Inctin1111Cili,mit11111,vviAnvillqsri9 t ArElLrnic,11,1_]=4niminn

2. iinIdm(DaAirAvEi111,611Lmsnct.orE1611,mmtluzi61,1,

a) mE3-AT,Efaithz.-,ntili-mq19A[Anyff(a.nngq4k)h-nznnw)-11-n. 2 IV3-.1M 11411(6ueviii-

b) Voltage Lvi 2 P11.1

C) nnJliiLwi1,17hilu, 2 LMJ 6101,M5,T11_16h1J jaraciA'AWVII.F1J1-12Virel_lrE3AT,VaNi rltJefeLd

d) nnT1,61imism,Awal iin 514rawNruDiat4i7i1nnA-mi,PnArEpadnrifet.,!.

e) 1adhaEnlcixhlmi'inlActn-nt-,1411

3. '6hi21,1,zmlnAirr- 11-11,rnlera3Ar)omnAminlInhi l

a) 61.] linanwinlmA'r)LLLI5s hzii(E3.0 LLmA(P11REli 91J

b) thst'i11M6L117,1PPYrJ111_12 LLAPAA'1F11_1 9IJ

C) a4.1 -̀‘1_1 611tlop linfl1P6111701F1°/%111J'ilinnnl LLA21A1HTl1 91_1

d) a2rdth:;rywvwhLLi_I5, cdin-JWr,,J 3'1_1i1V3p LalfrIlkINMJ

e) ‘-iArq, LLAPNA'1F1tU 1_121Wr,12

4. 61E12r1'1%11 ITILIJ(efP ee 111/7nLVI'D'i" lAkii nk141,,m

a) SiuLmi-NPwina,Fafit:imrriwv.n2n11.4nrinim.19x.i,lcrizq m

b) LTill4k11,1ThiLLLIMIAE1113715''IM'ILLINAL111I TLII:JVJUlq11

C) SiuLolitAkli ncLinw;16211ADVAculn-41„rrh3,,,

d) S.11,ApIlAvil.n.c:AnctAi'unrmuLn14171'A'Annnn5sazmAr,inniAILLutignS.IFILELA'A

e) S_IULATAliTIActlruun

5. ilElmolLtzlrnniv,.-,TmuTwEwNqLpigi'ill,61111.,Inna_ii,Sinii(61,1,ilwi3t-inlAinilq,J,8n -cuw-ilkiltTima.°5

ElmLA1(611,111.1

a) ol.1

b) CD-ROM

C)

d) Vil,rmtht,1.19xanml

e) nni'mazmlea

-4 .4 yrth-1114/11701'DU Teviwiroinwnlhipinliz-itrrinuLL81-,yonnnniet4vnAnnnnraifmn

Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Pencil
Sunton
Pencil
Sunton
Pencil
Page 3: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

- 3 - 511'erfitAnlii

6. 6himlaTIATinTt-dulmeia

a) vilfElcrAiltt4 (Printer)

b) 9(D3-.1EctIPI(Ei

c) kari.1.71A91.ivi(atTlinni-sonl

d) Tary-rwatrukz,i S

e) L3.1-4

7. LAirDlcievi'vr,o1612 rririnnsl2e.114n1 9;iiviiiu,e,lunT.°;2-114qurn

a) LFIlrall7U,11,41)1JUt,L'Hi"

b) 1,Airal7U-11N-LrumAiuvilln

C) 4 , E1170,14LLIJIIMVo.dviini

d) LAirDlY\IgEFRP(a .i

e) 13.in'iD612Qn 9,,,v

8. nniLtliy4191.,]MilLT.J1,A6rii7z-,rrrN-To-lnribluLm'mA(NA91,m1-4-11,191.,11 pi"(y /̀T-I.H1

coli1/2upYrAn iSkinuworinlA

a) 1 112

b) 4 va

c) 8 11 2

d) 16 '112

e) 32

9. iIrD6121,1-ii*n43-al-FriiNvil,:miA9n3.14nilliti Secondary Storage Unit

a) i'Armiiiii rakiNcioluTnPnirit:iinnrin RAM

b) OMMTnifni*-rb-Thl,), 1̀A41,3j3InT:.-,LdITan

c) '.1Ary-1.11,1-) 611,1finyhci,LilEn.A(DI„j,1.17111m

d) Tinm16Yro1 li,runliu inwirrALAL,11,vq13,imnz;m-Aun-ff1A-11,,Aiuikinn7 -,Thull

e) LtIvolurr161?Y1 inupwilinucilb'culinmLthanim_1=7npi-

10. (qi_InmiltriliD5WrnAnifii_lmn2N21,1,w..- Anz-litlArniP,L91,,n_knEtipinl-rirali.8191mfmAqL26

a) ur.11919wa-n

b) ciAl()NR9-11-Anvia-n

c)

d) warmi_l=we,1n2-11

e) vrt.,i9niim-naNm'u

A vy(in11.4nigArau Iyibluvim(ninRniconn7fricwa:_-/ymni-mmumonnmnniAnwi

Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Page 4: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

- 4 - ,y1mran,-,

11. il(d12b.i6lAcrinb-41.4111,Inn5lilmatImmLAvIArAvvef

a) Ty-N-11_1148w

b) nm-n9n9i

C) ci1nih'ILA11

d) nnblil

e) ctinWILLUA3.11A

12. Vfet-Inutl 1 FlIAJA- hadr4r11,1railIN

a) 8 ila

b) 1000"riF

c) 1024 i_ii

d) 8000 9:IF1

e) 8192 cia

13. VLIrMITII-Ardt2M-V-11,1M-.111-VIrlTiILLIcli/YEVirlff'11V4(61RalrJLR'Df ImwilmtrwmAna.c.5vIn1-1141A

alln-noli,=.4‘tan?i(nn

a) Harddisk

b) RAM

C) Thumb Drive

d) Floppy Disk

e) DVD-RW

14. i'l OA 9-2 SI u viryni n \IT v 1 en thia9 f T ni u Ilh' irk -ff (Operating System)

a) ISO

b) Lunux

c) Unix

d) Microsoft

e) OpenSource

15. iiviv4'P SiviMAliaqi:LL'avvaL.R6i11,1 (Application Software)

a) Unix

b) WindowsXP

C) Chrome OS

d) Ubuntu

e) GCC

: . _ -,- , e.4 Ip`i-pilunqqAtau Icah-in4Nrwmfflipmlururrni,taanAinnniLmulAmcryiPrmPinh-n

Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Page 5: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

- 5 - 51Teftramtii

IMPTI4FhPlEacll A'11)1;"1.1g-10111.1ATIA 1

ilia a b c d e ilv a b c d e

1 9

2 10

3 11

4 12

5 13

6 14

7 15

8

krial 2 91171'118RiiNVII.I'M 1/1/112:1'141(DAQ -4.1criLiimg-,ii n

(15 Ati)11414)

1. LVJUMJULAIJAMVDIArAF1(6fildA911),,IIATE11,111144(JUlqral /4'1 (RAM) 1-.1-Innrn9n1

M'13-.1?1'13-.1rlifllUiMthilq.19NWIJM CPU i'411rYn

2. ,Tr11,TEMPAnlflM1QLF1(431ArY13,1?S'13T-151111,1TM11=3.19Mall?Mn Super Computer

3. RAM oluvii,199n1Ancii?Sn'),,IrMil,r1trIE1.11, 1,Alm_1134-1iynn tildirri9t9_i2LhiatiLLMr1Fin3.1

4. 9raci711111111143.1N

5. Laalfil.1141,L111] Dot Matrix 4MISJI,d(61_1/1J1-601.1,irs1ffIrInAILAIM,r1,1T111A1141 1,31r6lirm9JSit19J

6. ii,n19111/14 clYion-aitl-Aunnuawc,5Liiuuchl 9 41 p.nlorlf2Firi.

lantIM9m-dyiwnloi(6041=LihlaLw,-,Triml-, u,cinn

7. Ti_ITann.i Dev C++

P1 nwi6169- 1-1u

8. an?InW-151-1,611thLLMI.Ithsn,.19n12'1 L'ii14 MS Word 61,unnA-11 Source Code

Compile IA

9. WILvqviLm-D1Rfla.ifni,FrnisictArin 1,1'11'11.46111M LilfacCrillimffmnymiEtiiin-m;ct,actni

aaimnnaciAn Ldfl\nnnt-plii.nizmiiconnwrt.nct.

10. 5 MB m,1,1SD Card 'in,r1mQn3-1 1 GB Irlthriu

200 JIM

- VOIT11,14/11/Ztatl IviwnwriftnIhNnloonm-flnuanctAinnmniuvmcirnnnTAny-i

Sunton
Typewriter
ผิด
Sunton
Typewriter
ถูก
Sunton
Typewriter
ผิด
Sunton
Typewriter
ถูก
Sunton
Typewriter
ผิด
Sunton
Typewriter
ถูก
Sunton
Typewriter
ผิด
Sunton
Typewriter
ผิด
Sunton
Typewriter
ผิด
Sunton
Typewriter
ถูก
Sunton
Typewriter
Page 6: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

- 6 - 51allaincH1

11. TntutlEu7innT Windows Phone 8 VAnwrailAln1_anns,P1611.,an

J°z',1J1111N11Y-1 i1Zli7i'1 lnuctivOrm-d1wmAri

12. 6Pim1713-1i9u61:0[01A99,1114 tAl fm-difficilLAiralAra3Arh,F1(afesi1`w Parallel Port

13.'11,01P ff'11,41.1V1I fl Serial Port 1.1`DllAa\IPMAM,VEf L'5-1171''1J-.11A31 LCA11713(a1.1F11 0,1_16,1PilmnT

(`I.,(ocv6fLci7o-i

14. 1091111,1 6T'IF14Pr)1.14111_FA9tPalViiQq_III/IMINYT Li'4`DLAraltlth_1-,1`)601i1nnAuLyi(DfLcilm

15. nlloirnivinumr-i 1,1711-4'(a1C/1114'11,VD141ilfacebook 1.rinc*131,1In

o„-1 ******** ******* n

..4 114i01114F115'Z'aU clilh-TeLrwn_lYiivinluTrmq-iritAwc:-_,wrinnim.JuvrtannnnniAnyi

Sunton
Typewriter
ถูก
Sunton
Typewriter
ผิด
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
ถูก
Sunton
Typewriter
ผิด
Sunton
Typewriter
ผิด
Sunton
Typewriter
****หมายเหตุ ตอนที่ 1 อาจจะเฉลยผิด ได้ น้องๆ ลองตรวจสอบดีๆ****
Sunton
Typewriter
Sunton
Typewriter
Page 7: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

-7 — SYiii.dfl f11-1 1

uvivi 2 n114-1 C (21 AtaLtru)

1. 91 oil.psiyElya\rii_ovai,tvin111,1,tu,NunTwawl\r-ii.o-raunnn/%unIth'LLnnat-,01 (3 lz--,Liptrt.A)

Sauce Code Object Code

7:dil 1 ar.r2nnIAR,L w11.4"_a(algrm th kv-iIannJ

2. 9'llinqi_hT,n-w*TrALIJ2P11_11,

9,917r1LAralVIL'IS ✓ x vieLniAitnraim (6 An1,141,)

2.1 int a = 3.0;

2.2 float if = 2.5;

2.3 char cl, c2, c3;

2.4 float integer = 4;

2.5 char lc, 2c, 3c;

2.6 unsigned int a='A';

1191'01114TYliZtall TY1W111,01'41(61HIJF11111,-a(MTIMULL8Z1AlilfriMMAIITAMPrIrlTgrlb-r1

Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
ผิด
Sunton
Typewriter
ผิด
Sunton
Typewriter
ถูก
Sunton
Typewriter
ถูก
Sunton
Typewriter
ผิด
Sunton
Typewriter
ถูก
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Compiler
Sunton
Typewriter
Sunton
Typewriter
Linker
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
ภาษาเครื่อง หรือไฟล์โปรแกรม
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
พี่ทรติวเตอร์
Page 8: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

-8 - nrvniniifnii

3. 91 011.111111911ii t1n Pal 161:te-&D1 fill Lt,m,l,LoolleAflali-tnalnt.ns34kli_let1

#include <stdio.h> (6 Piz,'Ll,uu)

#include <stdlib.h> int main() {

int a, x = 5; float b; printf("Enter an integer number: ");

scanf( );

printf("Your input value is \n",a);

printf("Enter a floating point number: ");

scanf( );

printf("Your input value is %f\n", );

printf("Size in byte(s) of x = %d", ) ;

printf(", and in bit(s)= %d", ) ; printf("Goodbye\n"); return 0;

1

;MiAig MalFaeh1/41altiiLit141Ailiantatint,nnA 10 lin' 20 P113.1101°'1J (6 m:.',LL'141,1)

***" `11.1111/1171 2 **"

L' 44 ,, ... .1' - -, ..4 ll'il01111/195-0Z1.1 TY1W11101f1MtliiiNlrI611,15-1E19111111,Lfltlirlf1MMUVIld1MAIY141111_41

Sunton
Typewriter
"%d ",&a
Sunton
Typewriter
%d
Sunton
Typewriter
"%f " , &b
Sunton
Typewriter
b
Sunton
Typewriter
sizeof(x)
Sunton
Typewriter
sizeof(x)*8
Sunton
Typewriter
Sunton
Typewriter
Enter an integer number : 10 Your input value is 10 Enter a floating point number : 20 Your input value is 20.0000000 Size in byte(s) of x = 4 , and in bit(s) = 32 Goodbye _
Sunton
Typewriter
Page 9: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

-9- nrmrfirtnIn

3 In5w1i'-ww)uppA (39 At11,141.4)

1. 910611 it Nfl -11■1 5- (Output) onl&nrimlti_lannwieli_lil (13 m:,11,1a,1)

-1 6-11M/1 M1. oHltthan23.1 NA'Aiti,As-inA-41

(1 nuuu)

int i=0; do { i+=3;

printf ("*") ; } while (i < 10) ;

2.

(2 mz-,ll141,1)

int i=0; while (i< 10) {

printf ( "%d", i) ; i+=2; 1

3

( 2 mnLuu)

int i; for (i = 0; i < 10; ++i)

if ( (3 < i) && (i <= 6)) printf ("A") ;

else printf ("B") ;

4.

(2 Az,'LLuu)

int i; for (i = 0; i < 10; ++i)

if( (i % 2) - 0) printf ("A") ;

else if ( (i % 3) == 0) printf ("B") ;

else printf ("C") ;

5.

( 2m:,-LLuu)

int i, j; for (i = 0; i < 5; ++i)

{ for(j = 0; j < i; ++j)

printf ("*") printf ("*\n") ;

}

6.

(2 nuuu)

int m=8, n=3, q=0, r; int ml=m; while (ml>n) {

ml=ml-n; q++; if (ml <n I I m1==0) r=m1;

} printf ("%d x %d + %d = %d\n" ,q, n, r, m) ;

( 2 AtLI,U14)

int i, j; for (i = 0; i < 3; ++i) {

for(j = 0;j < 2+i; ++j) printf("%c",65);

printf("\n"); 1

-?' TY1W1.11,1VIAtiff151111,1,151t1T/ITLILL8:51111M21,n11,0)11,1111r1MMAIM1

Sunton
Typewriter
****
Sunton
Typewriter
02468
Sunton
Typewriter
BBBBAAABBB
Sunton
Typewriter
ACABACACAB
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
* ** *** **** *****
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
2 x 3 + 2 = 8
Sunton
Typewriter
Sunton
Typewriter
AA AAA AAAA
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
พี่ทรติวเตอร์
Page 10: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

- 1 0 - 51fr111114111i 1

.." 2. irlffinlaill13Ithunnin-)J'A rnnt-iAnw-yallInPini_lninuqu 100 Au vil=mutlIcijuip-4

LLW:51Yti,16-17iPgitillrl 1,1,kVIATI-AVH11/1',1111,1J151.11AlaMTIAflI4ArIESIYIU (6 R151,1,WW)

&yucI'ilwnlvlit151LimIlAlv5vairiu o

C°AnuAnehym

TIJTunni

1.#include <stido.h> 2.int main() 3.{ 4. int i; /* loop counter */ 5. int type, score; /* inputs */ 6. int undergradTotal; /* sum of all

scores of undergraduates */ 7. int gradTotal; /* sum of all scores of

graduate students */ 8. int undergradCount; /* number of

undergraduates */ 9. int gradCount; /* number of graduate

students */ 10. for (i = 0; i < 100; ++i) { 11. /*obtain inputs */ 12. printf("Enter student type (1-

undergrad, any other number-grad):"); 13. scanf("%d", type); 14. printf("Enter the students score: "); 15. scanf("%d", score); 16. /*update the appropriate

total/counter combination */ 17. if (type = 1) { 18. undergradTotal += score; 19. ++undergradCount; 20. } else { 21. gradTotal += score; 22. ++gradCount; 23 } 24 1 25. /*produce output */ 26. if (undergradCount > 0) 27. printf("Undergraduate Avg: %.3f",

undergradTotal / 100); 28. if (gradCount > 0) 29. printf("Graduate Avg:%.3f",

gradTotal/100); 30. return 0; 31. 32. 33. 34.

1 u75- 1n1 Liitiu Preprocessor elm

1,1,:-.iicjniiiiiri #include<stdio.h>

2. Unilo ii

3. uniroil;

4. Uni1-4

5. unirocil

6. U7rvia1

7. um4-0114

8. 1.151141"171

9. uniNcri

10. U 77 Yl-frl il

11. LI 7714-aii

4., ,4 .4 ..1' ,4, ,.I .51 Vcalq1011141n9IN'aU IvneinalAtiaumnlurtyririula:5vinnmmumarvinn1TAnwl

Sunton
Typewriter
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Highlight
Sunton
Typewriter
**ให้เขียนส่วนที่ผิด แล้วอธิบายด้วย
Sunton
Typewriter
Sunton
Highlight
Page 11: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

ArltY13.1

Ar12(61J

3.1 1:1)ILLIJ1zirnriiralIthunsa.liir)-IvuolVi Lcriu nnAiiimr1

if -else (2 mccriuta,l)

switch( i ) {

case 0: case 1: n = 10;

break; case 2: n = 500;

break; default: n = 0;

break; }

3.2 112:669im&n.nyallth6Lnnicliiinv1. )Vi Siu niTliiAlg'l

do -while (2 ml'A6u1.4)

int sum = 0, num;

scanf("%d", &num); while (num >= 0) {

sum += num; scanf("%d", &num);

}

3.3 112,11iinue.m&ii;Hltthunn.i (6 P11",LLUct4)

#include <stdio.h> #define N 6 int main (void) {

int i, j; for (i = 1; i <= N + 1; i++) {

for (j = 1; j <= N; j++) { printf("%c",'A'+((i+j-2)%N));

} printf("\n");

I return 0;

}

-11 - 5Trrraanwi

3. 91W6uAnnna.iffifaltld (10 mn,Luto

L' ,, -r _ -, .4 c9,91-mlunqi-wau Ivri.6iicorinffiinipinici.Artyrruu,Livynn-mmuviuln-innnTAnwi

Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
if(i==0 ||i==1) n = 10; else if(i==2) n = 500; else n = 0;
Sunton
Typewriter
Sunton
Typewriter
int sum = 0, num; do{ scanf("%d",&num); if(num>=0) sum = sum + num; }while(num>=0);
Sunton
Typewriter
Sunton
Typewriter
ABCDEF BCDEFA CDEFAB DEFABC EFABCD FABCDE ABCDEF
Sunton
Typewriter
Page 12: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

........ ,,,•

,,,,, ............

- 12 -

4. Vik9no4-11?_J'114r jnItA'aiLLr -1j(DArriA;DLIAI'D'icilL9fL41-1?nu 1,L2lknilE4rIr1ME1

111LM-T1M 741A(D111'10,12/1 11,1914L11,11/14,11M91-5 631M'Elli'll'intUi I2EY11,1T'IPTH1

EilidLYDikd (10 Pn1)1A14)

1. (Table: 'T') LYintTu 4, 000unY1/FirJ

2. dini(Chair: 'C') vvinriii 2, 500unYi/N—q

3. IPATIAin (Sofa: '5') iyinnu 20, 000Lnclii/ArQ 4.

4. 'ir1,49-1161rD1 (Shelf: 'F') LvinrYu 10 , 0001T111/F1'r)

91LiimathanniImunnthAnct.nulu (Money) 9nneTIA LLMJT,Irrilmon1FluArinEln-144 -1-

ImAnsfn9unil-,y1"14-11,491,CrAn1noyDy9ninn 14m9nnstILInvITOE1LL?121 , 0 e, 0 v - inumAnTD 9'11,1rJUIA*1 lanntrlA rct4rYll'IYE1 1Q1,1114clUTLIL11,1311

vt4EfiLjAnl.rims..-ALA(DfilvvDR'nviti_ 1U1' (FlqtATL4V1121141,1.1M 11,1iLilt114Pi'@A11.414,9

cligl(i011,11/11IWDU IviwimpinmtlYuvInilanwririuLL2nNnnmniconompnnTAnwl

Sunton
Typewriter
#include<stdio.h> int main(){ int n,c_t=0 ,c_c = 0 , c_s=0,c_f = 0; char type; float total = 0; printf("Enter number Money : "); scanf("%d",&n); do{ printf("Enter type : "); scanf("%c",&type); switch(type){ case 'T' : n = n - 4000; c_t++; break; case 'C' : n = n - 2500; c_c++;break; case 'S' : n = n - 20000; c_s++;break; case 'F' : n = n - 10000; c_f++;break; default : n = n ; break; } }while(n>=2500); printf("number of Table = %d\n",c_t); printf("number of Chair = %d\n",c_c); printf("number of Sofa = %d\n",c_s); printf("number of Shelf = %d\n",c_f); printf("Money = %d\n",n); getch(); return 0; }
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Page 13: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

- 13- iTrran4nul

UYIY1 4ta-)415s6 (30 An61.411)

1. (N1Liz-,nnpiALLIJTmiLT6i)nvhului.1(61-pp-lvilild (6 loc,-,'LLct.,a,0

1.1 inlni,im.P1.61,14,' section 6H1TE1E9611'1 introcom 6illrnr11141 10 sections

1.2 oneim-'16,1tiqWYNTUYil 7 Tc1,411,MillkiPlniIfrifill,16134P%11 "Sunday"

, 1.3 Rc̀r,LIA,t1,12MA`ci,'41,1°H11,1.M.°111,11_11/1111,11 V11491,11111141.1M 60 0114

1.4 ir11,4TIA8TV103.11,ULOinfel-MAyliIMUT(D1-11,1L131/1111/11,1 611:1111-1141.12 3 Gl LI,P12 -',01 4

Int16laAu1Noni1t41 43.PT=-, 30 611QP 2 13.11LI-T'D\igl.M.,]:L82_1 LLwo'.-'4] A A - qpwritw1,8T(D101.1LIAltll 2 6111,,IR oiluonLL8°Q;6111,41111°111,1-',9'11,131,1 10 6n2

2. 911 1)1ILIJ1Lnnthinunle119/im.n,iml ILITurnmucrict4TIJTanT1.111,1nrithAn;11LP1.114(nesi-n.,

111-11;13.1PITIIMU 9c1r11,,AI.MA'11,1rJ1_,1 50 R1.,1 ImnArn,rm,19-InRnaTwai 4 j611TH1U.P1.1,LEI cc,1,'KU

(AMS11,1)1RtL11,11ALP118`L'7)11'1A 100 8Z-',LLUld) iinu.m.IARe,-,Lro,ffm-aJnnMliAvvinnii 200

nn,c2u11241(Dr-n,t.m.R1,1141,1ur.111,1 (12 RIAL141,)

viryninlNannihILITurinl (11a-ryninlAmFirH11,1.m.4fEur,inlinfilvila 30 R1,1)

Enter

Enter

Enter

Enter

Enter

Enter

Enter

Enter

Enter

Enter

Enter

Enter

score [1] [1] : 60

score [1] [ 2 ] : 60

score [1] [3] : 60

score [1] [4] : 60

score [2] [1] : 30

score [2] [2] : 45

score [2] [3] : 50

score [ 2 ] [4] : 40

score [50] [4] : 50

score [50] [3] : 40

score [50] [2] : 80

score [50] [1] : 90

}

}

liti --,LLI4uLL.P-1&.:-I'irrHlu.vii.mcA 1 il\n1r6ursnet

3"1_18n,LVI,ILLFial;).°11TH11,1.M.814171' 2 61111_213.iejni,

'''1J81-:LL1,1)P1':,(1611'1'1111,LP1.81411 50

Passed = 30

Ify(h11314TMA'aU TyiwioywninivinlurtynincwancAnnnmuconNnnpn-ffPny-i

Sunton
Typewriter
int num[10] ;
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
char name[7][21] = {"Sunday"};
Sunton
Typewriter
Sunton
Typewriter
float avg[60];
Sunton
Typewriter
int num[3][4] = {{30,30,30,30}, {0,0,0,0}, {10,10,0,0}};
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
พี่ทรติวเตอร์
Page 14: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

-14- 1/11:1'n n ii

4include<stdio.h> int main() f int i,j,scores[50][4];

int count=0,sum=0;

for( ) { sum=0; for( ) {

if(

count++;

printf("Passed = %d\n",count); return 0;

3. r lylitn-III_ITIAnn.J1un -inuiii8Q-13-.1 password rvin Imurincinoa password

thl-,r1EuArmk61blvilvwm 8 A'rJ iLkF1J194(ndrIS_11,1 password fikol'elaj

password Yinlull4 8 FirJ61H1dAfElthZ-MMALIA(MF-9611_112-irarVaVit-Li (A-Z)

1,Mnc-To2tHEirlli1M1 1 N-rJ IMElii-12VMMAL&MAILIdrIS_IU password riinci/i73.ilidn

"Good password" LLPiillmnSIAJud10% password itaill)licArIA%cl "Password is not

good" (12 Rc,',UVW

viryninlesirnNILTannikm _inA y 1

Enter password : New2Bolc (4j(M9MAnt-inP)

Good password

Ptin1N2n-inuI th unn.gryninlcii -rJ 2

Enter password: NewsBolc (ii(EPT);.ihisnnTI6I)

i Password is not good (Lctal9nn lapir)LaTir)a.v4_111,t password Lm)

vr'ivaurniZzu IcvihlloywnlYuRnlcontyrruaz-lAinnmmuvrt,AnnnryiTginwi

Sunton
Typewriter
i=0 ; i<50 ; i++
Sunton
Typewriter
j=0 ; j<4 ; j++
Sunton
Typewriter
Sunton
Typewriter
printf("Enter score[%d][%d] : ",i+1,j+1);
Sunton
Typewriter
scanf("%d",&scores[i][j]);
Sunton
Typewriter
sum = sum + scores[i][j] ;
Sunton
Typewriter
sum >= 200
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Page 15: MA1 KI,tc;)K9nmpirkroosuntorn.com/torntutor/attachments/article/7/Sol_56_2.pdf · 2018. 3. 1. · - 6 - 51allaincH1 11. TntutlEu7innT . Windows Phone 8 . VAnwrailAln1_anns,P1611.,an

- 15 - ITenTniitmui

......... ............. .......... • • ................. f ................

******** vijuvivi 4 ******

IviwwtainuLlYtiviniconnwriAL81-,YinnnJ1,nrwcolarrinn-ITPirryl

Sunton
Typewriter
#include<stdio.h> #include<string.h> int main(){ char pass[9]; int n =0 ,i; int ch =0,in =0; printf("Enter password : "); scanf("%s",&pass); for(i=0;i< strlen(pass);i++){ if(pass[i]>='A' && pass[i]<='Z') ch++; // ch = ch + 1; if(pass[i]>='0' && pass[i]<='9') in++; } if(ch>0 && in>0) printf("Good password \n"); else printf("Password is nod good\n"); getch(); return 0; }
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
Sunton
Typewriter
**************************แก้ไข