Skip to main content

Chapter 4 BABI NA BIYU (2)

Abinda ake kira ‘Keywords’ ko kuma mu kirashi da kalmomin umarni wasu irin kalmomine na musamman da ake adana su tare da kowacce irin harshen kirkirar manhaja sannan yana kasancewa tamkar wasu kalmomine da ake amfani da su a wajen bada umarni a harshen kirkira wanda sashen fassara wadannan kalmomi yake fassara duk wasu umarni da aka zayyano (compiler ko interpreter) domin cimma wata manufar aiki ko cimma wani dama. Alal misali a wannan littafin, mu dauka cewar kalmar ‘Bayana’ kalmace da take nuni da a bayyana rubutu a allon manunin komfiwta. Dokokin gina kalma (syntax): wasu jerin dokokine da ake amfani da su a wajen rubutu duk wasu umarni a harsunan kirkira.

Kamar dai yadda muka bayyana a babi na farko, rubutun ‘psewdocodde’ wani tsarin rubutune da yake wakiltar kalmomin umarni (keywords) a wajen tsara manhaja. Saboda haka; domin tunatarwa a wannan littafin zamu yi amfanine da irin wannan tsarin rubutun maimaikon asalin kalmomin umarnin da ake gina manhaja da su. Shi dama rubutun ‘psewdocode’ wani tsarin rubutune da ake amfani da shi domin a zayyana yadda tsari ko aikin manhaja zai kasance a rubuce da kowane irin yaren da kake iya fahimta kafin a fara rubutushi da asalin kalmomin umarni (Keywords)zuwa cikin na’urar komfiwta domin mai fassara (Compiler da interpreter) su fahimci umarnin sannan su fassarawa komfiwta umarnin shi kuwa ya aiwatar da aikin da aka saka shi. Zamu rinka amfanine da wannan tsarin na rubutu domin baka damar sanin tsare-tsaren da ake amfani da su domin a gina cikakkiyar manhaja. Sannan zamu yi amfani da wani tsari na jadawalin flochat (Flowchart) domin zayyana kamannin aikin manhajar a zahiri sannan kuma a zayyane wato domin zayyana yadda aikin manhajar zai aiwatu. Tsarin flochat wani tsarine da yake bada damar zayyana yadda manhaja zai yi aiki a zane. Shi wannan tsarin yana da wasu alamomi na musamman da idan aka sanya su to kuwa ana nufin wani umarni ne, kamar dai yadda idan aka ga wata kalma to kuwa kowa ya san ma’anarta da kuma abinda take nufi to hakama kowane alama a wannan tsarin yana da nashi kalar ma’anar ta musamman. A wannan babin zamu fara bude littafin ne da ma’anar abinda ake kira da ‘Variable’ wato ‘Tanadadden gurbin ma’aji’ a komfiwta. Tanadadden gurbin ma’aji a komfiwta (Variables): Suna ne na tanadadden gurbin ma’aji (Memory location) na komfiwta da ake sanya shi a yayin kirkirar manhaja domin ya kasance gurbin da ake son a adana wani bayani a cikinsa yayin da manhaja ya fara aiki. Sannan a gefe guda kuwa, zamu yi dubi ga abinda ake kira da

‘Data’ wato Bayani. Zamu yi bayani game da ma’anarsu, da kuma yadda ake aiki da su, sannan a karshe kuwa zamu yi dubi ga amfaninsu a wannan littafi namu. Sannan a gefe guda kuwa, zamu yi dubi zuwa ga dabaru ko hikimomi da ake bi a wajen amfani da harshen kirkira, dama yadda tsarin samar da manhaja yake. Sannan a karshen wannan babin, zamu zayyano misalai domin baka damar kara fahimta akan fahimtarka. Domin fara wannan babin bari mu tambayi kanmu menene bayanin ‘Data’ ?, me ya ‘Data’ ya zama mai muhimmanci ga na’urar komfiwta ? sannan kuma wani amfani yake da shi a wajen tsara manhaja ko a wajen duk wasu tsare-tsarenmu? Bayani (Data) abune mai matukar amfani a rayuwarmu na yau da kullum domin shine yake taimakarmu a wajen tsara duk wasu abubuwa da suke tafiya a cikin rayuwarmu sannan da shine muke iya zayyana abubuwa da suke tare da mu. Misali. mu kaddara kaine kake son sanin yawan dalibai da suke kowane aji, saboda haka sai ka fara bi kowane aji kana kirga yawan dalibai da suke ciki kana rubutawa. To wannan abinda kake karba ko kake yin sai ace kana karbar ‘Data’ wato Bayani. Saboda haka; idan ka kammala karbar wannan bayanan zaka iya zayyana sakamako da cewa aji kaza ya fi yawa ko aji kaza shine mafi kadan, ko kuma dai aji kaza shine tsaka-tsaki a wajen yawan dalibai. Bayani yana sa mutum ya fahimci abu yadda ya kamata. Domin sake sanin amfani ko muhimmancin bayani bari mu sake komawa zuwa misalinmu na dazu game da sanin yawan dalibai a kowacce aji. Bari muce kaine da abokinka kuke damuwa game da me ya sa ajinku ya zama shine karami akan ajin da yake gefenku. Saboda haka; sai kuka tambayi malaminku me ya sa ake samun wasu azuzuwan kanana wasu kuma manya ? sai malaminku yace ai yawan dalibai da suke aji shine yake sa ake samun aji ya zama karami ko babba. Saboda haka da kuka duba bayanan yawan dalibai da kuka dauka dazu sai kuka ga cewar ashe yawan daliban da suke ajin da yake gaba da ku ya ninka naku har sau biyu a wajen yawa, saboda haka kuka tabbatar cewar lalle hakane ashe yawan aji shi ya saka sa ake samun aji karami ko babba. To kuwa kaga anan, ashe wannan bayanan ya taimakeku a wajen sanin hakan. Saboda haka dai yanzu ka san ma’ana da kuma amfanin bayani a wajen zayyana wani bincike ko aiki. Tambaya ta gaba shine yaya ake amfani da bayani a wajen tsara manhaja ? Zamu yi bayanin hakanne a misalai na gaba masu zuwa. Mu kaddara cewar kaine kake son samar da manhajar da zai gano yawan dalibai da suke azuzuwan makarantarku. Saboda haka na san dolene sai ka bukaci bayanin hakan (Data) domin aiwatar da wannan aikin. To amma tambayar anan ita ce ta yaya za’a samu wadannan bayanan domin

manhajar ya gano yawan daliban ?, to kuwa za’a iya samun wannan bayanin ta hanyar mai amfani da manhajar, saboda haka idan ka zo gina manhajarka sai ka fara da saka inda manhajar zai tambayi mai amfani da manhajar akan ya “Saka yawan dalibai da suke aji na 1”. To wannan tambayar zai bayyanane da zarar manhajar ya fara aiki. To tambayar anan it ace ta yaya za’a fadawa na’urar komfiwta akan ya bayyana wannan rubutun a allon manuni ? , to sai muce ta hanayar daya daga kalmomin umarni na harsunan kirkira kamar kalmar ‘Bayyana’ (Display). Misali. Bayyana “Saka yawan dalibai da suke aji na 1” (sai ka saka wani jerin rubutu da kake son ya bayyana maka wanda kuma ba ‘variable’ ba. Yanzu idan ka karbi wannan bayanin yawan daliban, to kuwa kana bukatar wani ma’aji da zaka ajiyeshi domin amfani da shi anan gaba. To sai muce a ina kenan ? to fa ananne inda amfanin ‘Variable’ wato sunan tanadadden gurbin ma’aji zai yi amfani. Zamu iya daukar sunan tanadadden gurbin ma’aji (variable) a matsayin wani madaukine da zai kunshi duk wani bayanin da zai shigo anan gaba, sannan zai iya cenzuwa daga lokaci zuwa lokaci ya danganta da bayanin da aka shigo da shi a koda yaushe. A takaice dai; sunan tanadadden gurbin ma’aji wato ‘variable’ suna ne na gurbi da zai kunshi duk bayani mai shigowa daga waje domin amfanin manhajar. Akwai ire-iren ‘variable’ kala-kala, wasu suna rike lambobine zallah, wasun kuma harrufan bakake suke iya karba kadai. Ga kadan daga mafi shahara daga sunan nau’in bayanai da ‘variable’ zasu iya karba. Integer (sunan nau’in lambobi zallah). Nau’in lambobi maras goyo. Misali kamar; 2,67,88,11,23,67, -89, ko 56 da dai sauransu. as 2,67, -89, or 56

Real (sunan lambobi masu goyo zallah). Wadannan sune lambobi masu goyo, ma’ana lambobine da suke da digo. Misali kamar; 22.3, 4.2, 10.0 ko -43.8 da dai sauransu.

String (sunan nau’in harrufa zallah). Wannan kuma suna ne na nau’in jerin harrufa

zallah. Misali. “Mene ne sunanka”

Boolean (sunan nau’in zabin E ko A’a) Wannan kuwa sunan nau’in bayanine da zabinsa yake kasancewa E ne (True) ko kuwa A’a (False).

To a yanzu kuwa ka san irin nau’in bayanin da zaka iya adanawa a yayin gina manhaja kamar yadda muka ga nau’ikan bayanan a jadawalin da yake sama da ya gabata, to amma tambayar shine ta yaya zamu yi amfani da shi wannan tsarin a yayin gina manhaja ? mafi yawa daga harsunan kirkira sai sun bukaci da ka sanya sunan gurbin ma’aji (variable) kafin kayi amfani da shi a gaba, kamar dai haka: Sunan nau’in bayani farko (data type), sannan Sunan nau’in tanadadden gurbin ma’aji kamar haka → Integer farashi Misalin da yake sama, yana nuna mana yadda ake tanadar gurbin ma’ajine wato ‘variable’ da kuma yadda ake kaddara masa irin nau’in bayani (data type) da zai zama ya adana a ma’ajin da ya tanadar domin karbar duk wani bayanin da zai shigo yayin da ake amfani da manhajar. Sannan kalmar ‘farashi’ shine sunan tanadadadden gurbin ma’ajin, wato shine sunan ‘variable’ da zai sanya duk wani bayanin da zai shigo a nan gaba idan manhajar ya fara aiki, sannan kuma shi kalamar ‘farashi’ babu abin da zai iya adanawa sai dai nau’in lamba kawai amma idan aka sako da wani abu koma bayan lamba to kuwa manhajar zai nuna cewa akwai kuskure sannan ba zai yiwu ya adana wannan nau’in bayanin ba. Yanzu bari mu koma kan misalinmu na dazu. Bari mu kaddara cewar manhajarmu zai tambayi mai amfani da shi akan ya shigo da adadin yawan daliban da suke wadancen azuzuwan guda 3 sannan shi kuma manhajar yayi kokarin adanasu a wannan tanadadden gurbin ma’ajin mai suna ‘farashi’. Abinda ya kamata ka sani shine dolene mu yi amfani da nau’in bayanin lamba wato ‘integer’ saboda idan ba haka ba kuwa manhajarmu ba zai iya adana lambobin da aka shigo da su a

matsayin yawan dalibai da suke a wadancen azuzuwa uku ba saboda koda ya karbi bayanin to idan yayi kokarin adanasu to hakan ba zai yiwu ba. Wannan kuwa shine hikimar da yake bayan amfani da nau’in bayani na lambobi wato ‘integer’. Integer Aji 1 Integer Aji 2 Integer Aji 3 Bayyana “Saka yawan dalibai da suke a aji na 1’ Aji na 1 = saka adadi Bayyana “Saka yawan dalibai da suke a aji na 2’ Aji na 2 = saka adadi Bayyana “Saka yawan dalibai da suke a aji na 3’ Aji na 3 = saka adadi (Alamar nuna dai-daito wato ‘ = ‘ yana nuna yadda aka sanyawa kalmar ‘Aji’ wanda shine sunan tanadadden gurbin ma’aji (variable) da yake a matsayin nau’in bayani (data type) na lambobi zalla aikin adana duk wani bayani da zai shigo a nan gaba idan manhajar ya fara aiki). (Fa’ida: Idan ka duba a sama zaka ga cewar nayi amfani da kalmar na ‘integer’ kai tsaye, to abinda ya sa haka shine shi wannan kalma na ‘integer’ koda a kalmomin umarni (keyword) da suke a wasu harsunan kirkira kamar yaren ‘Visual Basic VB.net’ haka ake sanyashi a matsayin sunan nau’in bayani mai shigowa (data tyepe) sannan a saka sunan tanadadden gurbin ma’aji wato ‘variable’.

Saboda haka; wannan ne ya sa muka yi amfani da kalmar kai tsaye ba tare da sanya fassararsa a wato ‘lamba’). Saboda haka dai na san zaka fahimci cewar a wannan misalin namu da yake sama a duk sanda manhajar ya bayyana rubutun da aka rufeshi da ruwa biyu “ “ wato “Saka yawan dalibai da suke a aji na 3” to abinda manhajar zai yi shine ya dakata domin ya karbi bayani sannan ya adanashi a wancen sunan tanadadden gurbin ma’ajin (variable). Abinda muka yi a sama shi ake kira da sanya aiki wato zayyana aiki ga manhaja. Sannan idan muka ga dama zamu iya kaddarawa ‘variable’ namu wani lamba da zai zauna a madadinsa domin amfani da shi a wajen aiwatar da wani lissafi a cikin manhajarmu. Zaka iya sanyawa sunan tanadden gurbin ma’ajinka (variable) duk wani irin sunan da kake so matukar bai ci karo da ka’idojin da aka gindaya a wajen kirkirar sunan tanadadden gurbin ma’aji (variable) ba to amma fa ya danganta da nau’in harshen kirkirar da kake amfani da shi. To amma duk da haka akwai wasu zababbu kuma sanannun dokoki ga yawancin harsunan kirkira a wajen kirkirar sunan tanadadden gurbin ma’aji (variable) da ake amfani da su. Ga dokokin kamar haka: 1. Ba a sanya fili (space) a matsayin sunan tanadadden ma’aji (variable). 2. Ba a fara saka lamba a wajen kirkirar sunan tanadadden gurbin ma’aji (variable). 3. Ba a saka abinda ba lamba ko harrufa ko dai alamar da ake kira da ‘under_score’ wato wannan alamar ‘ _ ‘ a wajen kirkirar sunan tanadadden gurbin ma’aji (variable) ba. Alal misali.

Dangane da abinda ake kira da ‘camelCase’ wani tsarine na rubutu da ake rubuta kalmomi fiye da daya a tare da junansu ba tare da sanya fili ko wani ka’idojin rubutu a tsakaninsu ba sai dai a wajen rarrabe tsakaninsu ana amfani da babban harafi sannan kuma a sanya karamar harafi a mafarin rubutu. Wato a tsarin rubutun ‘camelCase’ ana iya rubuta wasu kalmomi masu ma’ana ko manufa daban–daban sannan kuma ba tare da rarrabe tsakaninsu da fili ko wani ka’idar rubutu ba sai dai a rabe tsakaninsu da manyan harrufa sannan kuma a fara da kananan harrufa. Misali. Integer YawanDalibaiAAji = Aji1 + Aji2 + Aji3 To kaga kuwa anan, mun sanya aiki da dama a lokaci guda. Da farko mun kaddara sunan nau’in bayaninmu (data type) a matsayin ‘Integer’ wato lambobi zallah, sannan sunan tanadadden gurbin ma’ajinmu (variable) kuwa shine YawanDalibaiAAji sai kuma muka sanya masa abubuwan da muke son ya rike mana a wajensa wato sune ya dauki abinda aka sako a matsayin ‘variable’ na Aji1 da Aji2 da kuma Aji3 ya hadasu sannan ya sanya sakamakon ga ‘variable’ na YawanaDalibaiAAji, saboda haka; a koda yaushe aka bukaci ‘variable’ mai suna YawanaDalibaiAAji da ya bayyana abinda yake cikinsa to sai ya hade abubuwanda ya samo a ‘variable’ ukun nan wato Aji1 da Aji2 da kuma Aji3 sannan ya bayyana sakamakon da ya samo. Wannan tsarin na bada aiki ga ‘variable’ shi ake kira da kaddarawa (Initialization). Abinda ake kira da kaddarawa (Initialization) shine bada wani aiki ko ajiya ga ‘variable’ domin ya ajiye maka wannan abin a cikinsa. Misali.

Integer Aji1 = 15, Aji2 = 35, Aji3 = 18 To kuwa kaga anan, mun samar da sunayen tanadadden gurbin ma’ajine guda uku sannan kowane aka kaddara (Initialize) masa lambar da zai ajiye mana a cikinsa. To yaya kenan idan muka sanya ‘variable’ amma ba tare da kaddara musu abinda zasu ajiye a cikinsu ba, kamar dai a misalin da muka gabatar a baya ? to kuwa wannan tsarin shi ake kira da ‘uninitialized variable’ wato sunan tanadadden gurbin ma’ajin da ba a kaddara masa komai ba. Saboda hakan dai shi sunan tanadadden gurbin ma’aji (variable) da ba a kaddara masa komai ba, so ake ya rinka adana abubuwa daban-daban a lokaci daban-daban yayinda manhajarka yake aiki, kenan. A yanzu zai iya adana 6 sannan anjima kuma ya adana 9 ko ya adana 77 kawai dai ya danganta da lambar da aka shigo masa da shi a yayin da manhajar yake aiki. Sannan kuma wannan shi zai bamu fahimtar cewar lalle idan bamu sanya masa komai a yayin da manhaja ya fara aiki ba sannan kuma muka bukaci yayi mana wani aiki da wannan sunan tanadadden gurbin ma’ajin (variable) to kuwa matsala zata iya faruwa saboda babu komai a cikinsa. A karshe dai game da maganar sunan tanadadden gurbin ma’aji (variable) kada ka manta matukar kana son amfani da su a cikin manhajar domin ka sanya manhajar yayi maka wani aiki na musamman to kuwa kana bukatar kaddara masa abinda zai rike kafin aikin ya yiwu.

Rubutun manhaja. Sakamakon rubutun. Integer Aji1, Aji2, Aji3 Integer AdadiNaTsakiya

Saka adadin dalibai da suke Aji na 1 → saka: 15

Integer Jimilarsu

Bayyana “Saka adadin dalibai da suke Aji na 1” Aji1 = Saka Bayyana “Saka adadin dalibai da suke Aji na 2” Aji3 = Saka Bayyana “Saka adadin dalibai da suke Aji na 3” Aji3 = Saka Jimilarsu = Aji1 + Aji2 + Aji3 AdadiNaTsakiya = Jimilarsu/3 Bayyana “Yawan daliban azuzuwa uku shine ” Jimilarsu, “sannan kuma adadi madaidaici kuma shine”, AdadiNaTsakiya

Saka adadin dalibai da suke Aji na 2 → saka: 20 Saka adadin dalibai da suke Aji na 3 → saka: 19

Yawan daliban azuzuwa uku shine 54 sannan kuma adadi madaidaici kuma shine 18

Kada fa ka manta da cewar shi ‘variable’ ana iya cenza masa abinda aka shigo masa da shi a duk lokacin da kake so, yanzu zaka iya sanya 5 sannan anjima ka sake sako 6 ko 111 da dai sauransu. To yanzu sai muce yaya zamu yi mu sanya ko kaddara wani abu da zai zauna a matsayin abinda zai rike mana a wajensa a koda yaushe? To wannan kuma shine tsarin da ake kira da ‘constant’ wato babu cenzawa. A wannan tsarin duk abinda aka kaddarawa ‘variable’ a matsayin abinda zai rike to baya taba cenzawa har abada. Shi wannan tsarin ana kaddara

abinda ake son ya rikene tun a wajen gina manhajar ba sai yayinda manhajar ya fara aiki ba. Alal misali, bari mu sake komawa kan misalinmu na dazu a game da sanin yawan dalibai da suke a kowane aji daga cikin azuzuwan ukun nan. Mu kaddara cewar makarantar taku aji guda ukune kawai gareta wato Aji 1, Aji 2 da kuma Aji 3. Sai kuma aka ce to a sanya manhajarmu ya samo mana yawan dalibai da suke a kowane Aji. A wajen yin wannan aikin ga dokokin da ake son ka bi su kamar haka: 1. Ba a bukatar canza lambar da aka sanya a matsayin shine adadin yawan dalibai da suke a wadannan azuzuwan koda manhajar ya fara aiki. 2. Sannan ana son idan aka sanya lamba to kuwa ana so ya kasance shine za’a iya amfani da shi a ko’ina a cikin manhajar idan aka tashi wani lissafi. Wannnan kuwa shi ya kawomu ga tsarin da ake kira da ‘number literal’ wato kaddararren lamba wadda bata taba canzawa a cikin manhaja. Amma fa ita wannan lambar ba ‘variable’ bane. To idan akayi amfani da cewa yawan azuzuwanmu yanzu guda 3 ne sai kuma daga baya aka samu Karin wani ajin ya zama 4, to fa abinda zaka yi shine dole sai ka je cikin rubutun manhajar ka cenza wancen 3 zuwa 4 saboda haka wannan zai sanya cenzawar 3 zuwa a ko’ina da ya zo a cikin manhajar. A takaice dai, abinda ake nufi anan shine shi tsarin da ake kira da ‘constant’ shine ka kaddara wata lamba ko wani harafi ko dai wani abu ga ‘variable’ tun a yayin gina manhajarka maimaikon barin ‘variable’ naka ya zama sai an fara amfani da manhajarne kake son

a shigo da abinda kake son ya wakilceshi. Misalin tsarin ‘constant’ shine integer Adadi = 3 To kuwa kaga anan duk inda aka yi amfani da ‘variable’ na ‘Adadi’ sannan aka tsara wani lissafi da shi to wancen 3 shine zai rinka zuwa a matsayin abinda yake cikin ‘variable’ din. A shawarce an fi son amfani da manyan harrufa a wajen tsara tsarin ‘constant’. Misali. Const Integer JIMILAR_AZUZUWA Wannan tsarin na ‘constant’ yana da dadi da kuma kawo sauki ga makirkira manhaja domin yana taimakawa a wajen takaice yawan rubutu a wajen gina manhaja sannan yana da saukin fahimta ga makirkiri. Wani abu kuma da yake karawa manhaja armashi sannan yake sanya fahimtarsa cikin sauki shine ka rinka sharhi (Comment) a yayin rubuta manhajar, ma’ana ana son ka rinka rubuta wani dan takaitaccen sharhi a kowacce gaba a cikin rubutun manhajarka domin karin bayani da kuma sanya saukin fahimtar alkiblar manhajar taka. Sharhi (Comment) shine zayyana Karin bayani a game da kalmomin umarni da kayi amfani da su a wannan wajen domin fahimtar aikin wannan gabar. Muna da nau’in sharhi kala biyune; akwai wanda ake kira da sharhi a layi guda (Line comment) da kuma sharhi mai yawa (Block comment). Shi kuwa yadda ake sanya sharhi a rubutun manhaja shine ta hanyar amfani da wani alama na musamman sai dai alamun sun banbanta daga

wani harshen kirkira zuwa wani, saboda haka idan kana so kayi sharhi a yayin rubuta manhaja to sai kayi la’akari da irin harshen kirkirar da kake amfani da shi domin yanayin alamar zai iya banbanta da wani. To amma dai a wannan littafin zamu yi amfani da alamar “//” Sharhi a layi guda (Line comment) yana karewane a layi tilo kawai. Ana amfani da shine a wajen yin takaitaccen karin bayani, misali. //Wannan ‘variable’ din ana son ya adana mana yawan azuzuwan dalibaine. Const Integer YAWAN_AZUZUWA (Fa’ida: idan ka duba zaka ga ana amfani da kalmar ‘Const’ a wajen gina tsarin “constant” (wato tsarin kaddara lamba da ake son kar ya cenza har zuwa karshen aikin manhajar) saboda shi kalmar na ‘Const’ shine yawanci ake amfani da shi a matsayin asalin kalmar umarni (Keyword) a yayin gina manhaja). Kamar yadda dai ka ga yanayin tsarin sharhin da aka yi a sama shine anyi sharhinne a layi guda ba tare da amfani da layika fiye da daya ba, saboda haka, zaka ga yana da saukin fahimtar abinda ake son a gabatar a wajen. Shi kuwa sharhin da ake kira da sharhi mai yawa (Block comment) shine sanya sharhi mai yawa da har zai dauki layi fiye da guda saboda bada cikakken bayani ga aikin wani gaba da yake wajen. Hakama shima alamar da ake amfani da shi a wajen yin sharhi mai yawa ya sha bamban daga wani harshen kirkiran zuwa wanin, to amma dai a wannan littafin namu, mun zabi wannan alamar ne “/*sanya sharhinka

anan*/ a wajen yin duk wani sharhi mai yawa. Yanzu bari mu dan waiwayi misalin rubutun mamhajarmu da muka yi dazu. Rubutaccen manhaja. Sakamakon rubutun. 1. /*Wannan manhajar anyi shi ne domin ya karbi yawan adadin dalibai na kowane aji 2. sannan ya lissafasu domin ya samo jimilar gaba daya azuzuwan tare da samo ajin da yake da yawan dalibai madaidaici wato

tsaka- 3. tsaki sannan ya bayyana

sakamakon abinda ya samo*/ 4. 5.Integer Aji1, Aji2, Aji3 //Yawan azuzuwanda muke da shi. 6.Integer AdadiNaTsakiya //Adadi na tsakiya 7.Integer Jimilarsu //Wannan kuma zai rike mana jimilar dukkansu azuzuwan. 8.Const Integer JIMILAR_AZUZUWA //Zai adana gaba daya jimilar azuzuwa guda ukunne anan. 9.

Saka adadin dalibai da suke Aji na 1 → saka: 15 Saka adadin dalibai da suke Aji na 2 → saka: 20 Saka adadin dalibai da suke Aji na 3 → saka: 19

Yawan daliban azuzuwa uku shine 54 sannan kuma adadi madaidaici kuma shine 18

10.//Zai tambayi mai aiki da manhajar 11.Bayyana “Saka adadin dalibai da suke Aji na 1” 12.Aji1 = Saka 13.Bayyana “Saka adadin dalibai da suke Aji na 2” 14.Aji3 = Saka 15.Bayyana “Saka adadin dalibai da suke Aji na 3” 16.Aji3 = Saka 17.Jimilarsu = Aji1 + Aji2 + Aji3 18.AdadiNaTsakiya = Jimilarsu/3 19.Bayyana “Yawan daliban azuzuwa uku shine ” Jimilarsu, “sannan kuma adadi madaidaici kuma shine”, AdadiNaTsakiya

Abu daya da ya kamata ka sani shine komfiwta baya karanta layin da aka yi sharhi. Saboda haka koda wani umarnine ka rubuta sannan ka rufeshi da wadannan alamu na sharhi to matukar komfiwta ya zo layin yana karantawa idan ya ci karo da wadannan alamu to kawai zai kyale layinne ya koma wani layin domin cigaba da karanta sharhin. Misali. idan ka sanya wani umarni kamar na Tarawa alal misali idan ka sanya umarinin cewa Aji1 + Aji2 to matukar ka sanya masa alamar sharhi a farkonsa

kamar haka //Aji1 + Aji2 to kuwa anan babu wani umarnin da zai bi na tara wadannan azuzuwa saboda ka sanya alamar sharhi. Saboda dama shi layin sharhi ana yinsane domin dan adam wato ya samu damar gane rubutun manhajar a gaba-gaba domin wannan zai bashi saukin gano wata matsala cikin sauki koda an samu kuskure a rubutun manhajar. Kafin dai mu kare wannan babin yana da kyau in ja hankulanmu a game da wani abu guda mai matukar muhimmanci. Idan ka dubi misalin rubutun manhajarmu da muka yi dazu zaka cewar munyi sa ne a layi-layi ma’ana daga wannan layin sai wannan. To kenan yanzu shin dolene a ce layi na 5 shine komfiwta zai fara aiwatarwa kafin layi na 12, 14, da 16 ? Domin mun riga da mun san cewar ba zai yiwu kayi amfani da ‘variable’ ba sai ka sanya shi sannan ka kaddara masa nau’in bayanin da zai rike (data type). Amsa ga wannan tambayar ita ce E hakane tabbas sai layin da ya fara zuwa ya aikatu kafin na kasansa shima ya aikatu wannan tsarin kuwa shine ake kira da ‘tsari mai bi daki-daki’ (sequence structure). Shi tsari mai bi daki-daki (sequence structure) wani tsarine da komfiwta yake karanta umarni a daki-daki wato mataki-mataki. Saboda haka; idan akwai wani umarni a layi na 1 to sai ya fara da karanta wanda yake kan wannan layin sannan ya sauka zuwa layi na 2, sannan na 3 sannan na 4 har zuwa karshen layikan umarnin. A gaba kadan a wannan littafin zamu kawo muku wasu hanyoyin na daban da komfiwta yake bi a wajen aiwatar da umarni dama yadda yake karanta layikan umarnin. Abinda yake kasa tsarin jadawaline na flochat (flowchart) da zai nuna mana yadda komfiwta

yake bi a wajen karanta layikan umarni a tsari mai bi daki-daki (sequence structure).

Zamu yi amfani da misalinmu na dazu na tara yawan daliban azuzuwa.

// Anan aikin manhajar ya fara aiki kenan.

// Wannan wajen kuwa anan ne ake kaddara sunan nau’in bayani (Data type) da kuma sunan gurbin ma’aji (Variable).

//Wannan wajen kuwa shine yake bayyana duk rubutun da aka rufeshi da alamar ruwa biyu wato “ da “ sannan kuma shine zai bada damar shigar da bayani zuwa ma’ajin Aji1, Aji2 da Aji3.

//wannan wajen kuwa shine zai aiwatar da Lissafin da ake son ya aiwatar.

// Anan ne zai bayyana sakamakon Abinda ya samo a lissafin da ya aiwa Tar.

//Wannan wajen kuwa ananne aikin ya dakata.

farawa

Int AdadiNaTsakiya; Int JIMILARSU; Int Aji1, Aji2, Aji3;

Bayyana “Saka adadin dalibai da suke aji na 1 Saka Aji 1 Bayyana “Saka adadin dalibai da suke aji na 2 Saka Aji 2 Bayyana “Saka adadin dalibai da suke aji na 3 Saka Aji3

Jimilarsu = Aji1 + Aji2 + Aji3 AdadiNaTsakiya = Jimilarsu/3

Bayyana “Yawan daliban azuzuwa uku shine ” Jimilarsu, “sannan kuma adadi madaidaici kuma shine”, AdadiNaTsakiya

kammalawa

A karshe dai yanzu, na san zaka dan fahimci wasu hikimomi a game da sha’anin kirkirar manhaja sannan a gefe guda kuwa na san ka dan fahimci yadda ake gina ko rubuta manhaja kamar yadda muka yi a rubutun manhajarmu na farko. Saboda haka ka nazarci wadannan matsaloli masu zuwa sannan ka amsa su domin karin samun fahimta.