Salon Ba Da Umarnin Gina Manhaja (Statements & Syntax) – 2

Isharar Ninninkawa ( ** )

Wannan ishara na aikin ninka adadi ne ninkin-ba-ninkin, kamar yadda Bahaushe ke cewa.  Misali, idan kana son ninka adadin 3 zuwa ninki 10, a fannin lissafi ana rubuta shi ne haka: 310, wanda kuma daidai yake da kace: (3 x 3 x 3 x 3 x 3 x 3 x 3 x 3 x 3 x 3 x 3).  Wannan shi ake kira: “Exponentiation” a ilimin lissafi da fannin kwamfuta ma.  Sai dai a bangaren gina manhajar kwamfuta ana amfani da alamar tauraro ne guda biyu, kamar haka: ( ** ), a sama, tsakanin lambobin da ake son rubanyawa ninki ba ninki.  Idan kana son rubanya wani adadi ninki-ba-ninki da wani adadi na lamba, a yaren Python, sai ka rubuta:

ninkinLamba = 32 ** 3

print(ninkinLamba)

Kana tambayar kwamfuta nan take za baka amsar 32768 a matsayin amsa.  A bangaren yaren JavaScript ma haka lamarin yake, wajen amfani da isharar.

 

Isharar Hadewa ( + )

Bayan tara wani adadi na lambobi da wani adadi, wannan ishara na hade wani adadi na harafi ko kalma da wata.  Wannan shi ake kira: “Concatanation” a ilimin gina manhajar kwamfuta.  Misali, idan kana son hade kalmar: “Baban” da kalmar “Sadik”, sai kawai ka rubuta:

sabuwarKalma = “Baban” + “Sadik”

print(sabuwarKalma)

Da zarar ka loda wannan umarni ga kwamfuta, ka bukaci ta bayyana maka abin da ke dauke cikin mazubin “sabuwarKalma”, nan take za ta aiko maka da: “BabanSadik”, a hade.  Wannan ta amfani da yaren Python kenan.

 

Isharar “Fiye Da…” ( > )

Wannan ishara da ita ake amfani wajen nuna fifikon wani adadi na yawa a kan wani adadi.  A harshen fannin lissafi ita ake kira: “Greater Than.”  Misali, idan kana son nuna cewa lambar 40 ta dara lambar 30 wajen adadi, sai ka rubuta: 40 > 30.  Ana amfani har wa yau da wannan ishara wajen tabbatar da gaskiyar wani lamari ko adadi ko zance.  Za mu zo mahallinsa nan gaba.

 

Isharar “Kasa Da…” ( < )

Wannan ishara kuma na tabbatar da nakasar wani adadi ne a kan wani adadi na lamba.  A harshen fannin lissafi ita ake kira: “Less Than.”  Misali, idan kana son nuna cewa lambar 30 kasa take da lambar 40 wajen yawa, sai ka rubuta: 30 < 40.  Kamar wacce ta gabace ta a sama, ana amfani da wannan ishara har wa yau wajen tabbatar da gaskiyar wani lamari ko adadi ko zance, amma ta bangaren gazawa ko nakasu.

 

Isharar “Daidai Da…” ( == )

Wannan ishara ce ke tabbatar da daidaito na adadi ko yanayi, tsakanin wata lamba da wata lamba, ko wani zance da wani zance.  A fannin lissafi ana kiran wannan ishara da suna: “Equal Than.”  Misali, idan kana son nuna cewa wata lamba daidai take da wata lamba, ko wani mazubin bayanai mai dauke da wata lamba daidai ko zance daidai yake da wani mazubi mai dauke da lamba ko zance irinsa, sai kace: 30 == 30.  Amsar wannan zai zama eh.  Kwamfuta za ta nuna maka “True” idan ka tambayeta.  Haka idan kace: babansadik = 1, da kuma BabanSadik = 1.  Da zarar ka tambayi kwamfuta cewa: babansadik == BabanSadik, za ta ce maka: “True.”  Ma’ana dukkan mazuban biyu na dauke ne da lamba 1.  Don haka duk da bambancin haruffansu, abu ne daya.

A yaren JavaScript akwai nau’i na biyu da ake rubuta ta kamar haka: ( === ), wacce suke kira: “Strict Equality,” wato “Hakikanin Daidaito.”  Wannan bambanci ne na salon yare da kowane yaren gina manhaja ke dashi.

 

Isharar “Ba Daidai Da…” ( =!, !=, ≠, ~=, /=, =/=, <> )

Wadannan isharori, a duk inda ka gansu tsakanin wasu zantuka biyu ko lambobi biyu, suna nufin rashin daidaito ne, ko dai na adadi ko na zance.  A fannin ilimin lissafi su ake kira: “Not Equal To.”  Ma’ana, ba daidai da adadi ko lamba ko zancen da ake kamanta su suke ba.  Kowane yaren gina manhaja yana da isharar da ya kebanta da ita cikin wadannan isharori da na kawo a sama.

 

Isharar “Fiye Da ko Daidai Da…” ( >= )

Wannan ishara ce mai harshen damo.  Tana nuna daidaito ne ko fifiko wajen adadi.  A fannin lissafi ita ake kira: “Greater Than or Equals to.”  Ana amfani da wannan ishara wajen kokarin tantance wasu sharudda kan wani adadi na yawa ne.  Ga misali cikin yaren Python nan:

lamba = 32

if lamba >= 32: print(‘Haka lamarin yake’); else: print(‘Ba daidai bane.’)

A bayanan dake sama na zuba lambar 32 ne cikin mazubi mai suna: “lamba,” sai kuma na jero umarni cewa, “In lambar dake cikin mazubin nan ta dara 32 ko daidai take da 32, to, ki rubuta: “Haka lamarin yake.”  In kuwa ba haka ba, to, ki rubuta: “Ba daidai bane.”  Da zarar na umarci kwamfuta ta zartar da wannan umarni, za ta rubuta: “Haka lamarin yake” ne.  Saboda mazunin “lamba” ta cika dayan sharuddan biyu.

 

Isharar “Fiye Da ko Daidai Da…” ( =< )

Wannan ishara kusan daya take da wacce ta gabace, sai dai ita tana kokarin tantance dayan sharadi biyu ne da aka gindaya mata wajen nakasa ko daidaito.  A fannin ilmin lissafi ita ake kira: “Less Than or Equal to.”  Ana amfani da wadannan isharori sosai wajen gina manhajar wasan kwamfuta (Computer Games).

 

Isharar Tazara (Space/Indentation)

Daga cikin isharorin da ake amfani dasu wajen baiwa kwamfuta umarni akwai amfani da tazara kamu daya wanda a harshen gina manhajar kwamfuta ake kira: “Spacing,”  sai kuma tazara mai kamu hudu, wanda ake kira: “Indentation.”  Wadannan isharori na tazara suna ma da mahimmanci sosai, iya gwargwadon kimar da aka basu a kowane yaren gina manhajar kwamfuta.  Galibi akan yi amfani dasu wajen kayatar da rubutattun umarni ne, wanda ake kira: “Code Readability.”  Sannan akan yi amfani da tazara mai ninki 4 (4 Space Indentation) wajen rubuta umarni mai sharadi (irin su: “If … then … else”).  Wannan kadan ne daga cikin ayyukansu.

 

Isharori Na Musamman

Bayan isharorin da suka gabata wadanda suke taimakawa wajen kintsa umarnin da ake baiwa kwamfuta, akwai wasu isharori ko alamomi na musamman da ake amfani dasu ta hanyar tsofa su cikin rubutattun umarnin da ake rubutawa.  Shahararru daga cikin su sune: => . , () {} [] & && ^ % $ # ! ~ | || ?.  Kowwannensu na da nashi matsayi da aiki.  A wasu nau’ukan yaren gina manhaja akan yi amfani dasu wasunsu dole, wasu kuma an so ne ayi amfani dasu (kamar kace: “Mustahabbi” ne).  sannan akwai wadanda ma sharadi ne shigar dasu, in kuwa ba haka ba, to umarnin bai zuwa ko ina.  Kwamfuta ma baza ta hankalci umarnin a matsayin umarni ba.  In ta yi dattaku ma kenan ta wuntsulo sakon kuskure (Error Message).  A wasu lokuta kuma ta maka shiru; kai baka samu biyan bukata ba, sannan ka kasa fahimtar dalili.

Baban Sadik

Baban Sadik marubuci ne, kuma mai bincike a fannin kimiyya da fasahar sadarwar zamani da tasirinsu ga al'umma a kasashen Afrika, musamman Najeriya. Ya tanadi wannan shafi ne don taskance dukkan kasidun da yake gabatarwa a shafinsa na jaridar AMINIYA mai take: "Kimiyya da Kere-kere," wanda ya faro tun shekarar 2006; shekaru goma kenan a takaice. Bayan kasidun shafin jarida, wannan shafi har wa yau yana dauke da wasu kasidun da ya gabatar a tarurruka da aka gayyace shi, ko wasu hirarraki da gidan rediyon BBC Hausa yayi dashi a lokuta daban-daban. Baban Sadik na zaune ne a birnin tarayyar Najeriya, wato Abuja.

2 thoughts on “Salon Ba Da Umarnin Gina Manhaja (Statements & Syntax) – 2

  • August 1, 2017 at 11:39 am
    Permalink

    Allah ya saka da alkhairi, hakika wannan darasi mai matukar amfani ga mu dalibai. Allah ya kara ma basira da karfin gwiwa.

    Reply
  • December 19, 2017 at 5:56 pm
    Permalink

    Allah ya saka da alheri malam ya kara nisan kwana muci gaba da amfana da baiwar da Allah yama.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *