An warware: hello duniya

Tabbas, na yi farin cikin rubuta labarin dangane da bukatunku. Gashi nan:

A cikin ainihin kowane harshe na shirye-shirye, aikin farko shine buga "Sannu, Duniya!". Wannan magana ta kasance al'ada ga novice shirye-shirye da suke samun kafa a cikin codeing. Shiri ne mai sauƙi wanda ya ƙunshi mahimman ayyukan harshe, yana sauƙaƙa wa masu farawa fahimta. Duk ta wannan, za mu nutse cikin zurfin C++, mu koyi yadda ake rubutu, tarawa, da aiwatar da wannan aikin tushen.

Rubutun Sannu, Duniya! Shirin a cikin C++

Don buga shirinmu mai zuwa, za mu buƙaci editan rubutu ko Integrated Development Environment (IDE). Rubutun Ƙarfafa, Notepad++, da Eclipse wasu shahararrun zaɓi ne don shirye-shiryen C++. Ga ainihin tsarin shirin:

#include
amfani da sunaye std;

int main () {
cout<< "Sannu, Duniya!"; dawo 0; } [/code] C ++ harshe ne mai girma, don haka rubutun ya fi kusa da turancin Ingilishi, wanda ke da amfani ga masu farawa. Kuna iya ganin "#include”- wannan umarni ne na riga-kafi wanda ya haɗa da daidaitaccen fayil ɗin iostream. The "amfani da sunan sararin samaniya std;" yana taimakawa wajen sauƙaƙa ma'anar C++, yana sa lambar ku ta zama abin karantawa. A ƙarshe, jikin shirin yana fitar da "Sannu, Duniya!" ta hanyar sanarwa.

Bayanin mataki-mataki na Code

Kashi na farko na shirin, “#include” babban ɗakin karatu ne inda cout, cin, da endl ke zama. A cikin shirye-shirye, dakunan karatu su ne na asali; sun ƙunshi lambar da aka riga aka haɗa waɗanda za a iya sake amfani da su, wanda ke hanzarta aiwatar da ci gaba.

Ga rugujewar lambar:

  • "#hada da” - Yana da alhakin haɗa shirin tare da daidaitaccen ɗakin karatu na C++.
  • "amfani da sunan sararin samaniya std;" - Ana amfani da wannan layin don gabatar da sararin sunan std.
  • "int main() {"- Wannan shine ainihin zuciyar kowane shirin C++.
  • "cout<< "Sannu, Duniya!";" - Abin da ake kira cout, haɗe tare da << ma'aikaci, yana fitar da kalmar da muke so.
  • dawo 0; - Hanya ce ta nuna nasarar aiwatar da shirin.
  • Rufewa } - Yana nuna ƙarshen shirin.

A kusa da "Sannu Duniya!" aikin yana haifar da ingantaccen tushe don mafari don fahimtar tsarin shirin C++. Ka tuna, wannan shine mafi asali nau'i na shirin. Yayin da kuke zurfafa zurfafa cikin C++, dole ne ku yi aiki tare da ƙarin ayyuka masu rikitarwa, ɗakunan karatu, da ƙirƙirar naku!

Laburare da Ayyuka a C++

Dakunan karatu da ayyuka sune kashin bayan kowane harshe na shirye-shirye. A cikin C ++, suna ba da izinin sake amfani da lambar, wanda ke haɓaka aiki sosai. Mun tabo wasu dakunan karatu kamar su iostream a cikin "Hello, Duniya!" code. Akwai ƙarin ɗakunan karatu marasa adadi a cikin C++, kowanne yana da takamaiman tsarin aikinsa.

Yin aiki tare da ayyuka muhimmin sashi ne na shirye-shirye. Aiki toshe ne na lambar sake amfani da ita wanda ke yin takamaiman aiki. Yayin da kuke ci gaba, zaku koyi game da ƙirƙirar ayyukan ku har ma da yin lodin su don yin ayyuka daban-daban!

C++ yare ne mai girman gaske, kuma yana farawa da binciken ku da "Sannu, Duniya!" zai iya saita sauti mai ban mamaki ga abin da ke zuwa.

Shafi posts:

Leave a Comment