LearnCProgramming
Keywords&Identifiers
Inthistutorial,youwilllearnaboutkeywordsandidentifiers.Keywordswhichare reservedwordsintheCprogramminglanguageandessentialpartsofitssyntax. Additionally,youwilllearnaboutidentifiersandtheprocessofnamingthem.Keywords andidentifiersarebothintegralfordefiningsyntax,semantics,andprecise communicationinCprogramming.
Keywords
KeywordsinCprogrammingrepresentreservedwordswithpredefinedmeanings.These wordscannotbeutilizedasidentifiers,suchasvariablenamesorfunctionnames. Thesekeywordsarepartofthelanguage’ssyntaxandservespecificpurposesinthe code.SomeexamplesofkeywordsinCprogramminginclude“if,”“else,”“for,”“while,” “int,”“float,”“return,”and“switch.”Thesekeywordsarecrucialfordefiningcontrol structures,datatypes,andotherfundamentalaspectsofCprogramming.
Forinstance:
Moneyisavariableoftypeint,asindicatedbythekeyword“int”inthissentence (integer).
In C programming, itisimportanttotypeallkeywordsinlowercasebecauseCisacasesensitivelanguage.
InCprogramming,Identifierreferstonamegiventovariousprogramelementssuchas variables,functions,arraysetc.Thesenamesenabletheidentificationandreferencing oftheseprogramelementswithinthecode.
Itisgoodpracticetochoosemeaningfulanddescriptivenamesforidentifiers,making thecodemorereadableandunderstandable.
For instance
intschool intschool; ; doublestudents doublestudents; ;
Here,wecanidentify“school”and“students”asidentifiers.
Also,keepinmindthatidentifiernamesandkeywordsmustbedistinct.Sinceintisa keyword,youcannotuseintasanidentifier
Rulesfornamingidentifiers
1.Theycanconsistofletters(bothuppercaseandlowercase),digits,andunderscores.
2.Thefirstcharacterofanidentifiermustbealetteroranunderscore.
3.TheyshouldnotbeakeywordorareservedwordinC.
4.IdentifiersinCprogrammingtreatuppercaseandlowercaselettersasdistinct, whichmeanstheyarecase-sensitive.
Identifiersmustbedistinct,astheyservethepurposeofprovidingauniquenametoan entitythatfacilitatesitsidentificationduringtheexecutionofanapplication.