masham 0 Report post Posted July 27, 2007 nih tutorial nyer yg 1stTUTORIAL: LOOPING1. What are the outputs for the following code segments?If the code is incorrect, how would you correct it?Given: int a=1; int b=10;a) while (a<5);{printf("%d",a);a++;}cool.gif while (a<5){printf("Hello world");printf("The value of a is %d", a);}c) do printf("Hello world");a++;while (a<5);d) while (a<5){ printf("Hello world");a++;while (b>6){printf("welcome to TAR \n");b--;}}ni kawan saya mintak tlg..hehehh...boleh ke nak mintak kawan2 putera tlg jawab..sebab sy dah lama tggalkan subject C++ nih..dulu ada belajar..skg dah x igt daa..kawan2 semua..tlg bagi jawapan utk tutorial ni beserta huraian sekali..kalau kawan2 sudi jawab..nak post tutorial lagi kat sini.. biggrin.gif ok..tima kasih Quote Share this post Link to post Share on other sites
putra 1 Report post Posted July 27, 2007 Salam Awang Selamat,Kalu betullah awak seorang kawan yang baik sangat nak tolong kawan siapkan assignment(yang asas sangat tu),apa kata minta tolong dia cuba untuk uji lari (test run) guna compiler dulu..Bukan apa, bimbang nanti dia dapat markah tinggi(biasanya org macam tu dpt markah tinggi ke?), tapi tak tahu apa.. Quote Share this post Link to post Share on other sites
spirit 0 Report post Posted July 27, 2007 mana C++ nya..nampak semer kod C jek.tak tau C pon leh setelkan benda ni. Quote Share this post Link to post Share on other sites
blind_control 0 Report post Posted July 27, 2007 memang c pon.... buat la tracing.... sonang je pakcik oiii Quote Share this post Link to post Share on other sites
jesseclane 0 Report post Posted July 27, 2007 asal ramai yang mtk jwpn ek? kat http://google.com byk jwpn woo Quote Share this post Link to post Share on other sites
versanner 0 Report post Posted August 1, 2007 hahahaha cam soklan assignment jer.......do ur own research, kalau x, sia2 jer blaja...nnti luper LAGI Quote Share this post Link to post Share on other sites
interferens 0 Report post Posted August 15, 2007 a) while (a<5);{printf("%d",a);a++;}jawapan: 1234cool.gif while (a<5){printf("Hello world");printf("The value of a is %d", a);}jawapan:Hello worldThevalue of a is 1c) do printf("Hello world");a++;while (a<5);jawapan:Hello worldHello worldHello worldHello worldd) while (a<5){ printf("Hello world");a++;while (b>6){printf("welcome to TAR \n");b--;}}jawapan:Hello worldwelcome to TARHello worldwelcome to TARHello worldwelcome to TARHello worldwelcome to TARmacam ni la kot jawpan dia..aku main agak je..xcompile pun.... Quote Share this post Link to post Share on other sites
MatchMaker 0 Report post Posted August 17, 2007 (edited) a- while (a<5); <-- nothing going on sebab nih{printf("%d",a);a++;}b- infinite loopc- syntax errord- Hello worldwelcome to TAR welcome to TAR welcome to TAR welcome to TAR Hello worldHello worldHello world Edited August 17, 2007 by MatchMaker Quote Share this post Link to post Share on other sites
Rizuwan 0 Report post Posted August 21, 2007 alahai.. kalau ini C... kalau C plas plas kepala dia laen sket... gune iostream... he he he... well.. blaja laa... ini asas segala asas ni untuk programming... kalau soalan tu rumit baru la kite same2 selesaikan... Quote Share this post Link to post Share on other sites
BdkPoli 0 Report post Posted September 4, 2007 Apa pulak beza a++ ngan ++a @ a-- ngan --a? Quote Share this post Link to post Share on other sites
CFoo++ 4 Report post Posted September 4, 2007 (edited) Apa pulak beza a++ ngan ++a @ a-- ngan --a? Cam ni....a++ - Kandungan a akan di increment selepas expresiContoh...int a = 5;y = a++; // Kat sini y = 5 sebab a belum di incremen semasa assign ke yy = a; // Kat sini a = 6++a - Kandungan a di incremen sebelum expresiContoh...int a = 5;y = ++a; // Kat sini y = 6 sebab a diincremen dulu sebelum assign ke yy = a; // Kat sini pun a = 6Yang --a dan a-- pun sama cume di decrement Edited September 4, 2007 by CFoo++ Quote Share this post Link to post Share on other sites