Sunday, September 16, 2018

C++ Function များ



Zawgyi


C++ မွာ fumction ေတြကို အသံုးျပဳပံု
===========+==========+===========
က်ေတာ္တို႔ computer ကို လုပ္ေစခ်င္တ့ဲ processes ေတြကို statement ေလးေတြေရးၿပီ ဘယ္ဟာကို ဘယ္လိုလုပ္မယ္ ဒီဟာျဖစ္ရင္ ဟိုဟာကိုပါ ဆက္လုပ္မယ္ စတ့ဲ instructions ေတြပါတဲ့ codes ေတြကို ေရးတယ္ေပါ့ေနာ္ ။ဒီေတာ့ငါတို႔လည္း သိတာေပါ့လို႔ ေတြးေကာင္းေတြးႏိုင္ပါတယ္။ 😁😁 က်ေတာ္ေျပာခ်င္တာက codes ေတြကို main() ထဲပဲ ေရးေနရင္ေတာ့ ဒီေန႔ေရးၿပီး ေနာက္ေန႔ျပန္ၾကည့္တ့ဲခါက်ရင္ ႐ူပ္ေနတတ္ပါတယ္ အဲဒါေၾကာင့္လဲ programmer ေတြ ဟာသ အေနန႔ဲ ေျပာၾကတာက ' a day before only God and me know, but now only God know ' ဆိုၿပီးေတာ့ေပါ့။
ဒါမ်ိဳးက beginners ေတာ္ေတာ္မ်ားမ်ား ျဖစ္ေနၾကပါ က်ေတာ္လည္း ေလ့လာတာ သံုးလ ေတာင္မျပည့္ေသးဘူးဆိုေတာ့ က်ေတာ္လည္း beginner 😪😪 ပါပဲ။ ကဲကဲ အေၾကာင္းရာကို ဆက္လိုက္ၾကရေအာင္ အ့ဲလို code ေတြ complex ျဖစ္တ့ဲ ျပသနာ ကို အေကာင္းဆံုးေျဖ႐ွင္းႏိုင္မယ့္ နည္းလမ္းကေတာ့ main() ထဲမွာ တျခား function ခြဲေတြ ေခၚသံုးဖို႔ပါ ။ဒီ subfunction ေတြကို ခြဲသံုးရတာက အဓိက ရည္ရြယ္ခ်က္ႏွစ္ခု ႐ွိတယ္ဗ် ။
(1) code ေတြ ႐ွင္းလင္းမူ႐ွိေအာင္
(2) အႀကိမ္ႀကိမ္လုပ္ေဆာင္ရမယ့္ process ေတြအတြက္ အခ်ိန္ကုန္သက္သာေအာင္ပါ

အေပၚက (2)ခ်က္က programmer ေတြတြက္ မွန္ေပမယ့္ hacker ေတြအတြက္ေတာ့ (3)ခ်က္လို႔ေျပာရမယ္ဗ် ။ပိုသြားတ့ဲအခ်က္ကေတာ့ harmful ျဖစ္ေစမယ့္ virus ေတြေရးဖို႔ပါ။ ဘယ္လိုေရးလဲ ဆိုေတာ့ကာ 😙အဟြန္း အဟြန္းေျပာၿပီေနာ္ ဥပမာ a န့ဲ b ဆိုတ့ဲ process ႏွစ္ခု ႐ွိတယ္ဆိုပါစို႔ဗ်ာ a ထဲမွာ b ကို ျပန္ေခၚသံုးမယ့္ function ပါသလို b ထဲမွာလည္း a ကို ျပန္ေခၚေပးမယ့္ function ပါမယ့္ေပါ့ဗ်ာ
ကဲ a ကေန စအလုပ္လုပ္မယ္ ဗ် ဒီေကာင္ကို anti-virus ကသိၿပီး ျဖတ္လိုက္မယ္ ဆိုပါစို႔ a က ပ်က္သြားရင္ b ကို ဆက္အလုပ္လုပ္ လုပ္မယ္ အ့ဲမွာ b ထဲမွာ a က ပ်က္သြားခ့ဲရင္ a ကို ျပန္လုပ္ပါဆို႔တ့ဲ function ပါလာၿပီဆိုင္ရင္ ခနကလိုပဲ anti-virus က b ကို virus မွန္းသိလို႔ ဖ်က္လိုက္ပါဦး a ကျပန္အလုပ္လုပ္မယ္ a ထဲမွာလည္း b ကို ျပန္ေခၚထားမယ္ဆိုရင္ a ကို ဖ်က္လိုက္ရင္ b ကို ျပန္အလုပ္လုပ္မယ္ ကဲေသၿပီေလ ။တစ္ခ်ိဳ႕ VB တို႔ .Net တို႔န႔ဲ ေရးထားတ့ဲ malware ေတြက OS ေရြးတယ္ဗ် C,C++ က ေတာ့အ့ဲလို မဟုတ္ဘူး ခင္ဗ်ားသာ ဧတဒတ္ ရၿပီးသား hacker တစ္ေယာက္ျဖစ္ခ့ဲမယ္ဆို user က တစ္ခ်က္မွားလိုက္တာန႔ဲ system ႀကီးတစ္ခုလံုး access ရႏိုင္ၿပီး ႀကိဳက္သလို controll လုပ္လို႔ရပါတယ္။ ဘာလို႔ဆို C, C++ န့ဲ Assembly ဆိုတာက OS ဖန္တီးတ့ဲခါ မပါမျဖစ္ပါရတာမို႔လို႔ပါ ဒီ languages ေတြက hardware န့ဲ ခ်ိတ္ၿပီး kernel က တစ္ဆင့္ ထိန္းခ်ဳပ္အလုပ္လုပ္လို႔ပါ ။ ကဲမဆီမဆိုင္ေတြေတာ့ ၿပီးၿပီဗ်ာ စာဖတ္သူလည္း ဗဟုသုတ ေရာက္ေလာက္ေရာေပါ့ ဒါဆို function ပါတ့ဲ C++ program တစ္ပုဒ္ စၾကည့္လိုက္ရေအာင္ဗ်ာ



ကဲစမယ္.....
အရင္ဆံုး processing directive ေခၚထည့္တယ္ အေသးစိတ္ကိုေတာ့ Array in C++ ဆိုတ့ဲ page မွာ ျပန္ၾကည့္ပါ main() function က စအလုပ္လုပ္မယ္။
ထိပ္စီးပိုင္းက ပံုမွန္ေရးေနၾကအတိုင္းပဲ line 3 မွာ void fun(int i=0, intj=1) မွာ void ဆိုတာ valueless လို႔ေျပာတာပါ fun ဆိုတာက function name ပါ ႀကိဳက္သလိုေပးလို႔ရပါတယ္ သု syntax န့ဲ ညီေအာင္ေတာ့ ေပးေပါ့ဗ်ာ parthesis '()' ထဲက int i န့ဲ j ကို argument လို႔ေခၚပါတယ္ ၿပီးေတာ့ သူတို႔ ထဲမွာ 0 န့ဲ 1 ဆိုတ့ဲ values ေလးေတြ assign လုပ္ထားတယ္ေနာ္ ။ဟုတ္ၿပီ အ့ဲ fun ဆိုတ့ဲ function ကို void type main() အျပင္ဘက္ န့ဲ ေပၚဘက္မွာ ေၾကညာထားတာက main() ဆီကို return ျပန္မယ့္ေကာင္က void အမ်ိဳးအစာလို႔ေျပာတာျဖစ္ပါတယ္ ။ တကယ္လို႔ double fun လို႔ေၾကညာထားရင္ return ျပန္မယ့္ေကာင္က double အမ်ိဳးစားပါ ။ void မွာေတာ့ အ့ဲ function ထဲမွာပဲ statement ေတြကို တိုက္႐ိုက္ execute လုပ္လိုက္မွာ ျဖစ္ၿပီး main() ဆီကိုေတာ့ ဘာ တန္ဖိုးမွ return ျပန္လို႔ရမွာ မဟုတ္ပါဘူး ။ ဥပမာ d = a*n; return d;ဆိုရင္ေတာ့ error ျဖစ္သြားမွာပါ အကယ္လို႔ return d အစား cout << d; ဆိုၿပီး ေရးမယ္ဆိုရင္ေတာ့ မွန္ပါတယ္ aန႔ဲn ရ့ဲ ေျမာက္လဒ္ကို ထုတ္ေပးမွာပါ။ အဓိက ေျပာခ်င္တာက ကိုယ္က return ျပန္မယ့္ fun ရ့ဲ အမ်ိဳးစားကို ေသခ်ာ ေၾကညာဖို႔ပါပဲ ။ line 9 မွာ fun(2,3) ဆိုၿပီး ေရးထားတယ္ေနာ္ ဒါကို run တ့ဲခါက် compiler က fun ဆိုတ့ဲ function ဆီကို သြားမွာျဖစ္ၿပီး အ့ဲ function ထဲမွာ ႐ွိတ့ဲ statement ေတြကို execute လုပ္ၿပီး result ထုတ္ေပးမွာ ျဖစ္ပါတယ္ ။ အ့ဲေတာ့ i ရ့ဲေနရာမွာ 2 ဝင္သြားၿပီး j မွာေတာ့ 3 ျဖစ္သြားၿပီေပါ့ cout ဆိုၿပီး "" ထဲ႐ွိတ့ဲေကာင္ေတြကို screen မွာ ထုတ္ေပးမယ္ ၿပီး i တန္ဖိုးထုတ္ ၿပီးရင္ j တန္ဖိုးထုတ္မယ္ နားလည္ပါတယ္ေနာ္ ။ ဒီမွာ တစ္ခုုဖတ္ေျပာခ်င္တာက main() ေအာက္နားက fun(int b,int c) ဆိုၿပီးေတာ့လည္း declare လုပ္ေပးလို႔ရပါတယ္ ေျပာခ်င္တာက argument အေရအတြက္ တူရင္ အလုပ္လုပ္ပါတယ္ ဗ်ာ။funtion ေတြကို declare လုပ္တ့ဲ argument အေရတြက္ကို မတူပဲ function name တစ္ခုထဲေပးလို႔ရပါတယ္။ ၿပီးေတာ့ ေနာက္တစ္ခုက function ေတြကို main() အေပၚမွာပဲ ေရးမယ္ဆိုရင္ အေပၚတစ္ခါ ေအာက္တစ္ခါ ႏွစ္ခါ declar လုပ္စရာမလိုပါဘူး။ line 11 မွာfun(4) တစ္မ်ိဳးတည္းေရးထားတာက i တန္ဖိုးကိုသာ ေျပာင္းလဲၿပီး j တန္ဖိုးကေတာ့ ေျပာင္းလဲမွာ မဟုတ္ပါဘူး ။
j တန္ဖိုးကိုပဲ ေျပာင္းခ်င္တယ္ ဆိုရင္ေတာ့ i တန္ဖိုးလိုက္ျပန္ထည့္တာပဲ ျဖစ္ျဖစ္ variable တစ္ခုခုကို main() ထဲမွာ local အေနန႔ဲ declar လုပ္ၿပီး pass လုပ္ေစတာပဲ ျဖစ္ျဖစ္ ရပါတယ္။
return 0 ကေတာ့ program ၿပီးဆံုးၿပီလို႔ အတိအလင္းေၾကညာလိုက္တာပါ။ မပါလည္း ရပါတယ္။ေနာက္မွ local န့ဲ global အေၾကာင္းကို post သက္သက္ တင္ေပးပါ့မယ္ အားလံုးပဲ enjoy ပါ C,C++ က ဘာသာအားလံုးရ႕ဲ mother language ျဖစ္တ့ဲအတြက္ ေလ့လာရ ခက္ခဲပီး pro အဆင့္ထဲ ျဖစ္သြားၿပီ ဆိုရင္လည္း အျခား language ေတြကို ေလ့လာဖို႔ လြယ္ကူသြားမွာပါ။

#Hein Arkar
-Wtobe Shining Star

Unicode





C++ မှာ fumction တွေကို အသုံးပြုပုံ
===========+==========+===========
ကျတော်တို့ computer ကို လုပ်စေချင်တဲ့ processes တွေကို statement လေးတွေရေးပြီ ဘယ်ဟာကို ဘယ်လိုလုပ်မယ် ဒီဟာဖြစ်ရင် ဟိုဟာကိုပါ ဆက်လုပ်မယ် စတဲ့ instructions တွေပါတဲ့ codes တွေကို ရေးတယ်ပေါ့နော် ။ဒီတော့ငါတို့လည်း သိတာပေါ့လို့ တွေးကောင်းတွေးနိုင်ပါတယ်။ 😁😁 ကျတော်ပြောချင်တာက codes တွေကို main() ထဲပဲ ရေးနေရင်တော့ ဒီနေ့ရေးပြီး နောက်နေ့ပြန်ကြည့်တဲ့ခါကျရင် ရူပ်နေတတ်ပါတယ် အဲဒါကြောင့်လဲ programmer တွေ ဟာသ အနေနဲ့ ပြောကြတာက ' a day before only God and me know, but now only God know ' ဆိုပြီးတော့ပေါ့။
ဒါမျိုးက beginners တော်တော်များများ ဖြစ်နေကြပါ ကျတော်လည်း လေ့လာတာ သုံးလ တောင်မပြည့်သေးဘူးဆိုတော့ ကျတော်လည်း beginner 😪😪 ပါပဲ။ ကဲကဲ အကြောင်းရာကို ဆက်လိုက်ကြရအောင် အဲ့လို code တွေ complex ဖြစ်တဲ့ ပြသနာ ကို အကောင်းဆုံးဖြေရှင်းနိုင်မယ့် နည်းလမ်းကတော့ main() ထဲမှာ တခြား function ခွဲတွေ ခေါ်သုံးဖို့ပါ ။ဒီ subfunction တွေကို ခွဲသုံးရတာက အဓိက ရည်ရွယ်ချက်နှစ်ခု ရှိတယ်ဗျ ။ 
(1) code တွေ ရှင်းလင်းမူရှိအောင်
(2) အကြိမ်ကြိမ်လုပ်ဆောင်ရမယ့် process တွေအတွက် အချိန်ကုန်သက်သာအောင်ပါ

အပေါ်က (2)ချက်က programmer တွေတွက် မှန်ပေမယ့် hacker တွေအတွက်တော့ (3)ချက်လို့ပြောရမယ်ဗျ ။ပိုသွားတဲ့အချက်ကတော့ harmful ဖြစ်စေမယ့် virus တွေရေးဖို့ပါ။ ဘယ်လိုရေးလဲ ဆိုတော့ကာ 😙အဟွန်း အဟွန်းပြောပြီနော် ဥပမာ a နဲ့ b ဆိုတဲ့ process နှစ်ခု ရှိတယ်ဆိုပါစို့ဗျာ a ထဲမှာ b ကို ပြန်ခေါ်သုံးမယ့် function ပါသလို b ထဲမှာလည်း a ကို ပြန်ခေါ်ပေးမယ့် function ပါမယ့်ပေါ့ဗျာ 
ကဲ a ကနေ စအလုပ်လုပ်မယ် ဗျ ဒီကောင်ကို anti-virus ကသိပြီး ဖြတ်လိုက်မယ် ဆိုပါစို့ a က ပျက်သွားရင် b ကို ဆက်အလုပ်လုပ် လုပ်မယ် အဲ့မှာ b ထဲမှာ a က ပျက်သွားခဲ့ရင် a ကို ပြန်လုပ်ပါဆို့တဲ့ function ပါလာပြီဆိုင်ရင် ခနကလိုပဲ anti-virus က b ကို virus မှန်းသိလို့ ဖျက်လိုက်ပါဦး a ကပြန်အလုပ်လုပ်မယ် a ထဲမှာလည်း b ကို ပြန်ခေါ်ထားမယ်ဆိုရင် a ကို ဖျက်လိုက်ရင် b ကို ပြန်အလုပ်လုပ်မယ် ကဲသေပြီလေ ။တစ်ချို့ VB တို့ .Net တို့နဲ့ ရေးထားတဲ့ malware တွေက OS ရွေးတယ်ဗျ C,C++ က တော့အဲ့လို မဟုတ်ဘူး ခင်ဗျားသာ ဧတဒတ် ရပြီးသား hacker တစ်ယောက်ဖြစ်ခဲ့မယ်ဆို user က တစ်ချက်မှားလိုက်တာနဲ့ system ကြီးတစ်ခုလုံး access ရနိုင်ပြီး ကြိုက်သလို controll လုပ်လို့ရပါတယ်။ ဘာလို့ဆို C, C++ နဲ့ Assembly ဆိုတာက OS ဖန်တီးတဲ့ခါ မပါမဖြစ်ပါရတာမို့လို့ပါ ဒီ languages တွေက hardware နဲ့ ချိတ်ပြီး kernel က တစ်ဆင့် ထိန်းချုပ်အလုပ်လုပ်လို့ပါ ။ ကဲမဆီမဆိုင်တွေတော့ ပြီးပြီဗျာ စာဖတ်သူလည်း ဗဟုသုတ ရောက်လောက်ရောပေါ့ ဒါဆို function ပါတဲ့ C++ program တစ်ပုဒ် စကြည့်လိုက်ရအောင်ဗျာ 



ကဲစမယ်.....
အရင်ဆုံး processing directive ခေါ်ထည့်တယ် အသေးစိတ်ကိုတော့ Array in C++ ဆိုတဲ့ page မှာ ပြန်ကြည့်ပါ main() function က စအလုပ်လုပ်မယ်။
ထိပ်စီးပိုင်းက ပုံမှန်ရေးနေကြအတိုင်းပဲ line 3 မှာ void fun(int i=0, intj=1) မှာ void ဆိုတာ valueless လို့ပြောတာပါ fun ဆိုတာက function name ပါ ကြိုက်သလိုပေးလို့ရပါတယ် သု syntax နဲ့ ညီအောင်တော့ ပေးပေါ့ဗျာ parthesis '()' ထဲက int i နဲ့ j ကို argument လို့ခေါ်ပါတယ် ပြီးတော့ သူတို့ ထဲမှာ 0 နဲ့ 1 ဆိုတဲ့ values လေးတွေ assign လုပ်ထားတယ်နော် ။ဟုတ်ပြီ အဲ့ fun ဆိုတဲ့ function ကို void type main() အပြင်ဘက် နဲ့ ပေါ်ဘက်မှာ ကြေညာထားတာက main() ဆီကို return ပြန်မယ့်ကောင်က void အမျိုးအစာလို့ပြောတာဖြစ်ပါတယ် ။ တကယ်လို့ double fun လို့ကြေညာထားရင် return ပြန်မယ့်ကောင်က double အမျိုးစားပါ ။ void မှာတော့ အဲ့ function ထဲမှာပဲ statement တွေကို တိုက်ရိုက် execute လုပ်လိုက်မှာ ဖြစ်ပြီး main() ဆီကိုတော့ ဘာ တန်ဖိုးမှ return ပြန်လို့ရမှာ မဟုတ်ပါဘူး ။ ဥပမာ d = a*n; return d;ဆိုရင်တော့ error ဖြစ်သွားမှာပါ အကယ်လို့ return d အစား cout << d; ဆိုပြီး ရေးမယ်ဆိုရင်တော့ မှန်ပါတယ် aနဲ့n ရဲ့ မြောက်လဒ်ကို ထုတ်ပေးမှာပါ။ အဓိက ပြောချင်တာက ကိုယ်က return ပြန်မယ့် fun ရဲ့ အမျိုးစားကို သေချာ ကြေညာဖို့ပါပဲ ။ line 9 မှာ fun(2,3) ဆိုပြီး ရေးထားတယ်နော် ဒါကို run တဲ့ခါကျ compiler က fun ဆိုတဲ့ function ဆီကို သွားမှာဖြစ်ပြီး အဲ့ function ထဲမှာ ရှိတဲ့ statement တွေကို execute လုပ်ပြီး result ထုတ်ပေးမှာ ဖြစ်ပါတယ် ။ အဲ့တော့ i ရဲ့နေရာမှာ 2 ဝင်သွားပြီး j မှာတော့ 3 ဖြစ်သွားပြီပေါ့ cout ဆိုပြီး "" ထဲရှိတဲ့ကောင်တွေကို screen မှာ ထုတ်ပေးမယ် ပြီး i တန်ဖိုးထုတ် ပြီးရင် j တန်ဖိုးထုတ်မယ် နားလည်ပါတယ်နော် ။ ဒီမှာ တစ်ခုုဖတ်ပြောချင်တာက main() အောက်နားက fun(int b,int c) ဆိုပြီးတော့လည်း declare လုပ်ပေးလို့ရပါတယ် ပြောချင်တာက argument အရေအတွက် တူရင် အလုပ်လုပ်ပါတယ် ဗျာ။funtion တွေကို declare လုပ်တဲ့ argument အရေတွက်ကို မတူပဲ function name တစ်ခုထဲပေးလို့ရပါတယ်။ ပြီးတော့ နောက်တစ်ခုက function တွေကို main() အပေါ်မှာပဲ ရေးမယ်ဆိုရင် အပေါ်တစ်ခါ အောက်တစ်ခါ နှစ်ခါ declar လုပ်စရာမလိုပါဘူး။ line 11 မှာfun(4) တစ်မျိုးတည်းရေးထားတာက i တန်ဖိုးကိုသာ ပြောင်းလဲပြီး j တန်ဖိုးကတော့ ပြောင်းလဲမှာ မဟုတ်ပါဘူး ။ 
j တန်ဖိုးကိုပဲ ပြောင်းချင်တယ် ဆိုရင်တော့ i တန်ဖိုးလိုက်ပြန်ထည့်တာပဲ ဖြစ်ဖြစ် variable တစ်ခုခုကို main() ထဲမှာ local အနေနဲ့ declar လုပ်ပြီး pass လုပ်စေတာပဲ ဖြစ်ဖြစ် ရပါတယ်။
return 0 ကတော့ program ပြီးဆုံးပြီလို့ အတိအလင်းကြေညာလိုက်တာပါ။ မပါလည်း ရပါတယ်။နောက်မှ local နဲ့ global အကြောင်းကို post သက်သက် တင်ပေးပါ့မယ် အားလုံးပဲ enjoy ပါ C,C++ က ဘာသာအားလုံးရဲ့ mother language ဖြစ်တဲ့အတွက် လေ့လာရ ခက်ခဲပီး pro အဆင့်ထဲ ဖြစ်သွားပြီ ဆိုရင်လည်း အခြား language တွေကို လေ့လာဖို့ လွယ်ကူသွားမှာပါ။

#Hein Arkar
-Wtobe Shining Star
.hide { text-indent: 100%; white-space: nowrap; overflow: hidden; }li a { display: block; width: 40px; height: 40px; background-image: url(social.png); } li a.twitter { background-position: 0 0; } li a.fb { background-position: 0 -40px; } li a.gplus { background-position: 0 -80px; } li a.linkedin { background-position: 0 -120px; } li a.dropbox { background-position: 0 -160px; } li a.pinterest { background-position: 0 -200px; }

Wednesday, September 5, 2018

C++ Arrays




Hello Guys, ဒီနေ့တော့ C++ program လေးတစ်ပုဒ်ကို ရှင်းပြသွားပါမယ်ဗျာ do you know? ကျောင်းက ဘော်ဒါ တော်တော်များများက codes တွေကို အလွတ်ကျက်နေကြတာတွေ့လို့ ဒီ post လေးရေးဖို့ ဆုံးဖြတ်လိုက်တာပါ ။ ဒီ post က ကျောင်းက ဘော်ဒါတွေအတွက်ဆိုတော့ တစ်ခြားတစ်ယောက်က လာကြည့်ရင် ရူပ်နေလိမ့်မယ်။ဒါကြောင့်ကျော်သွားလိုက်ပါ။ စာမေးပွဲလည်း နီးပြီဆိုတော့ basic လောက် အထောက်ကူရအောင်ထိ ရှင်းပြထားပါတယ် second semester ကစတာကတော့ module 4 ပေါ့နော် ။ အစဦးဆုံး array နဲ့ဆိုင်တဲ့ပုဒ်ကို ရှင်းပြထားပါတယ်။ဒီ program ကို ငါ့ဘာငါ reference လုပ်ထားတာနော် အကုန်လုံးတူချင်မှတူမယ် ။ 😁😁 တော်ပါပြီလေ ကျတော်လို့ပဲ ပြောတော့မယ်။Let's Start.



ဒီ program ကို အစကနေ အဆုံးထိ trace လုပ်ကြည့်မယ်ဆွင်
#include <iostream> ဆိုတာက directive processing တစ်ခုပဲဖြစ်ပါတယ် iostream ဆိုတဲ့ header file ထည့်ဖို့တွက် #include ဆိုတဲ့ directive ကနေ command ပေးတာ ဖြစ်ပါတယ်။ ဘာလို့လဲဆိုတော့ကာ iostream ဆိုတဲ့ standard header file မှာ functions တွေ classessတွေ နဲ့ globel value တွေ ပါနေတာကြောင့်ပေါ့။ angle blacket < > ကတော့ အထဲမှာ ပါတဲ့ header file ကို compiler ကနေ support လုပ်ပေးပါလို့ အမိန့်ပေးတာပေါ့နော်။နောက်တစ်ခု line 2 က using namespace std ဆိုတာကတော့ cout နဲ့ cin ကို ယူသုံးလို့ရအောင်လို့ပေါ့ဗျာ ။
OK နောက်တစ်ကြောင်း ထပ်ကြည့်လိုက်ကြရအောင် 
အဲ့မှာ main() ဆိုတဲ့ function နဲ့ စတယ်ဗျ ဒီကောင်ကတော့ နာမည်နဲ့လိုက်အောင် program တစ်ခုလုံးရဲ့ အသက် function ပါပဲ ။ကျတော်တို့ ရေးချင်တဲ့ program ကို အဲ့ main() function ထဲမှာ ရေးရပါတယ်။အော်မေ့လို့ main() လို့ရေးလည်းရတယ်နော် int main() ဆိုတာကတော့ main() function ကို return ပြန်မယ့်ကောင်က int data type လို့ပြောတာပါ အွန်း ရူပ်သွားပြီလားဗျ နောက်တော့ တဖြည်းဖြည်းနားလည်သွားပါလိမ့်မယ် ကျတော်လည်း begineer အဆင့်တုန်းက ဒီလိုပါပဲဗျာ သင်တန်းကောင်းကောင်းမတက်နိုင်တော့ ကိုယ်တိုုင် self study လုပ်ခဲ့ရတာဗျ ဘာလို့ဆို ကျောင်းက သင်တာတွေကို နားရေမဝခဲ့လို့လေ ။ 
ကဲကဲ အချိန်မရှိဘူး ဆက်လိုက်ကြရအောင် main() ဖွင့်ပြီးဆိုတာနဲ့ curly brace '{}' လေးကိုရေးရပါတယ် ကျတော်တို့ ရေးမယ့် programs က အဲ့ အတွင်းမှာပဲ ရှိနေရပါမယ်။
line 7 က int i,j;ဆိုတာက i နဲ့ j ဆိုတဲ့ identifiers ကို data type က int လို့ပြောတာပါ နောက်မှ data type တွေ identifiers အကြောင်းတွေကို အေးဆေး ရှင်းပြပါ့မယ် ။
line 8 က cout statement က တော့ double quote ("") ထဲကရှိသမျှ letter တွေအကုန် screen မှာ display ပြမှာ ဖြစ်ပါတယ် အဲ့ screen မှာ Enter a number ဆိုပြီး ပေါ်လာမယ် OK. cin statement ကတော့ user က ရိုက်ထည့်လိုက်တဲ့ number ကို j ထဲမှာ ထည့်မှာဖြစ်ပါတယ်။ endl ဆိုတာက \n နဲ့့ တူတူပဲ next line လို့ပြောတာ နောက်စ်ကြောင်းပေါ့နော်။ line 11 က data type ကို unsigned int လို့ declar လုပ်တာက hein_arkar131429 ဆိုတဲ့ identifier က plus only လိုပြောတာပါ signed ဆိုရင် minus ရော plus ရော အကျုံးဝင်မှာဖြစ်ပြီး တန်ဖိုးအနေနဲ့ -32000 ကျော်ကနေ +32000 ကျော်ထိ ဝင်ဆံ့့မှာပါ ။ အဲ့ထက်ကျော်ပြီး number သွားထည့်ရင်တော့ error ပေါ့ဗျာ။



အဲ့မှာ hein_arkar131429 l[j] က array တစ်ခု ပြန်ပြောရရင် unsigned int က data type ၊ hein_arkar131429 က သုဘာသာ သက်သက်ရပ်တည်နေရင် identifier ဒီမှာတော့ array name ဖြစ်သွားပြီ OK. ကျတောတို့ ခနက user ဆီက input တောင်းခဲ့တဲ့ numberကို j ထဲမှာထည့်ခဲ့တယ်နော် ထားပါတော့ user က 4 ဆိုပြီထည့်လိုင်ပြီ ဒါဆိုရင် j တန်ဖိုးက 4 ၊ hein_arkar131429[4] ဆိုပြီးဖြစ်သွားပြီ၊ ဒီမှာမှတ်ထားရမှာက array တွေက အများအားဖြင့် တစ်ခုကနေ သုံးခုထိ ရှိပါတယ် one dimensional array,two dimensional array,multidimensional array စသဖြင့်ပေါ့နော် ။ ဒီမှာတော့ one dimensional array ရှိမယ် OK ၊ 
Line 13 မှာ တစ်ချက် show ကြည့်ရအောင် for looping လာပြီ first semester တုန်းက သင်ခဲ့ရတယ်မလား မညာချင်စမ်းပါနဲ့ကွာ အဲ့လယ် 😁😁 ဒါပေမယ့် နားမလည်ခဲ့ဘူးမလား ထပ်မညာချင်စမ်းပါနဲ့ကွာ စတာပါ အတည်ပါ အော် ကဲကဲ ရှင်းပြီနော် သေချာမှတ် for looping ပတ်တယ်ဆိုတာက process ကို အထပ်ထပ် လုပ်တာပါ တကယ်လို့ for looping သာ မရှိခဲ့ရင် တူညီတဲ့ လုပ်ငန်းတစ်ခုကို အကြိမ်ကြိမ်လုပ်ရမှာပါပဲ ဟုတ်တယ်ဟုတ် မဟုတ်လည်း ဟုတ်လိုက်😁😁 ၊ Ok ကျတော်တို့ i ကို 0 ကနေ စတယ် ။ C++ မှာ '=' က assignment ပါ၊ '==' ကမှ equal to နော ်မှားမှာ ဆိုးလို့ ၊ i က j ထက် ငယ် သရွေ့ i ကို 1 တိုးပြီး ဆက်တိုက် looping ပတ်မယ် OK. ပထမ looping

 ပတ်တော့ i က 0 ဆိုတော့  hein_arkar131429 [0] = 0
ဖြစ်သွားမယ် နောက်တစ်ခါ loop ထပ်ပတ်မယ် i++ နဲ့ i=i+1 နဲ့ တူတယ် အဲ့တော့ နဂိုရှိပြီးသား i တန်ဖိုး 0 ကို 1 ပေါင်းတော့ i က 1 ဖြစ်သွားပြီ condition ကိုကြည့်လိုက်တော့ i က 10 က ငယ်သေးတယ် ဆက်လုပ်မယ်အဲ့တော့ hein_arkar131429[1] = 1 ဖြစ်သွားမယ် အဲ့လိုပဲ i ကို 1 ပေါင်းသွားမယ် 10 ထိငယ်သရွေ့ ဆက်လုပ်မယ် 10 ထက်ကြီးသွားရင်တော့ looping က ထွက်သွားပြီး နောက်တစ်ခုကို ဆက်အလုပ်လုပ်မယ် အဲ့မှာ std::cout ကိုတွေ့တယ်နော် cout နဲ့ တူတူပါပဲ အဲ့မှာ \t ဆိုတာ tab ခုန်မယ်လို့ပြောတာပါ space ခြားမယ်ပေါ့ ရိုးရိုးခြားသွားလည်း no problem နောက်တစ်ကြောင်းဆင်းပြီး အလုပ်လုပ်ဦးမယ် တွေ့ပြန်ပြီ for looping အပေါ်ကရှင်းပြခဲ့တဲ့ အတိုင်းပါပဲ ကိုယ့်ပါသာကိုယ်သာ trace လိုက်ကြတော့ ရိုက်ရတာ လက်ညောင်းတယ် triple အဲ့လယ် 😁😁 ဒီမှာ တစ်ခုသတိထားရမှာက for looping လုပ်မယ့် process က တစ်ခုတည်းဆို curly brace ထည့်စရာမလိုဘူး တစ်ခုထပ်ပိုရင် ထည့်ပေါ့။ 
အားလုံးမှန်မှန်ကန်ကန်ရေးနိုင်ရင် ouput က အောက်ကအတိုင်းပဲပေါ့။

 အားလုံးအဆင်ပြေပါစေ တခြား CS ဘော်ဘော် တွေဆီ ပြန်လည်မျှဝေလိုက်ပါဦးနော် ။ 

#Hein Arkar
-Wtobe Shining Star

Monday, September 3, 2018

History OF AI Apps



History of Artificial intelligence


Here is the history of AI during 20th century 
Year Milestone / Innovation

1923 Karel Čapek play named “Rossum's Universal Robots” (RUR) opens in London, first use of the word "robot🤖" in English.
1943 Foundations for neural networks laid.
1945 Isaac Asimov,😎 a Columbia University alumni, coined the term Robotics.
1950 Alan Turing introduced Turing Test for evaluation of intelligence and published Computing Machinery and Intelligence. Claude Shannon published Detailed Analysis of Chess Playing as a search.

1956 John McCarthy coined the term Artificial Intelligence. Demonstration of the first running AI program at Carnegie Mellon University.
1958 John McCarthy invents LISP programming language for AI.
1964 Danny Bobrow's dissertation at MIT showed that computers can understand natural language well enough to solve algebra word problems correctly.
1965 Joseph Weizenbaum at MIT built ELIZA, an interactive problem that carries on a dialogue in English.
1969 Scientists at Stanford Research Institute Developed Shakey, a robot, equipped with locomotion, perception, and problem solving.
1973 The Assembly Robotics group at Edinburgh University built Freddy, the Famous Scottish Robot🤖, capable of using vision to locate and assemble models.

1979 The first computer💻-controlled autonomous vehicle🚙, Stanford Cart, was built.
1985  Harold Cohen created and demonstrated the drawing program, Aaron.
1990 Major advances in all areas of AI −
Significant demonstrations in machine learning
Case-based reasoning
Multi-agent planning
Scheduling
Data mining, Web Crawler
natural language understanding and translation
Vision, Virtual Reality

Games🎮


1997 The Deep Blue Chess Program beats the then world chess champion, Garry Kasparov.

2000 Interactive robot pets become commercially available. MIT displays Kismet, a robot with a face that expresses emotions. The robot Nomad explores remote regions of Antarctica and locates meteorites.


Applications of Artificial intelligence


AI has been dominant in various fields such as 

Gaming 🎮− AI plays crucial role in strategic games such as chess, poker, tic-tac-toe, etc., where machine can think of large number of possible positions based on heuristic knowledge.

Natural Language Processing − It is possible to interact with the computer that understands natural language spoken by humans👨

Expert Systems − There are some applications which integrate machine, software, and special information to impart reasoning and advising. They provide explanation and advice to the users.

Vision Systems − These systems understand, interpret, and comprehend visual input on the computer. For example,
A spying aeroplane ✈️takes photographs, which are used to figure out spatial information or map of the areas.🗺️
Doctors use clinical expert system to diagnose the patient.
Police 🚓use computer software that can recognize the face of criminal with the stored portrait made by forensic artist.

Speech Recognition − Some intelligent systems are capable of hearing and comprehending the language in terms of sentences and their meanings while a human talks to it. It can handle different accents, slang words, noise in the background, change in human’s noise due to cold, etc.

Handwriting Recognition − The handwriting recognition software reads the text written on paper by a pen or on screen by a stylus. It can recognize the shapes of the letters and convert it into editable text.

Intelligent Robots🤖 − Robots are able to perform the tasks given by a human. They have sensors to detect physical data from the real world such as light, heat, temperature, movement, sound, bump, and pressure. They have efficient processors, multiple sensors and huge memory, to exhibit intelligence. In addition, they are capable of learning from their mistakes and they can adapt to the new environment.


#Latest Technology Blog

C++ Function များ

Zawgyi C++ မွာ fumction ေတြကို အသံုးျပဳပံု ===========+==========+=========== က်ေတာ္တို႔ computer ကို လုပ္ေစခ်င္တ့ဲ processes ေတြ...