C/C++ Keywords and their uses

C/C++ Keywords and their uses

Keywords are reserved words that have special meaning to the compiler. They cannot be used as a variable name or identifier. All the keywords are written in lowercase. There are 32 keywords in C and 63 keywords + 11 (extra) in C++ which are not needed when ASCII characters are used.

Here’s the list of all C and C++ keywords with their respective uses:

KeywordPurposeC or C++
asmInserts an assembly instructionC++
autoDeclares a local variableC,C++
boolDeclares a boolean variableC++
breakBreaks the loop and control is out of the loopC,C++
caseA block of code in a switch statementC,C++
catchHandles exceptions of throwC++
charDeclares a character variableC,C++
classDeclares a classC++
constDeclares data or functions that do not change valueC,C++
const_castCasts from const variablesC++
continueBypass iterations of a loopC,C++
defaultDefault handler in a switch statementC,C++
deleteMakes memory availableC++
doDeclares do-while loopC,C++
doubleDeclare a double precision floating-point variableC,C++
dynamic_castPerforms runtime castsC++
elseAlternate case for an if statementC,C++
enumCreate enumeration typesC,C++
explicitOnly use constructors when they exactly matchC++
exportAllows the separation of definition of template from its usagesC++
externTell the compiler about variables defined elsewhereC,C++
falseThe boolean value of falseC++
floatDeclare a floating-point variableC,C++
forDeclares for loopC,C++
friendGrants non-member function access to private dataC++
gotoJumps to a different part of the programC,C++
ifExecutes code by checking a conditionC,C++
inlineOptimizes calls to short functionsC++
intDeclares an integer variableC,C++
longDeclares a long integer variableC,C++
mutableOverrides a const variableC++
namespacePartitions the global namespace by defining a scopeC++
newAllocates dynamic memory for a new variableC++
operatorCreates overloaded operator functionsC++
privateDeclares private members of a classC++
protectedDeclares protected members of a classC++
publicDeclares public members of a classC++
registerRequest that a variable be optimized for speedC,C++
reinterpret_castChanges the type of a variableC++
returnReturns a value from a methodC,C++
shortDeclares a short integer variableC,C++
signedModifies variable type declarationsC,C++
sizeofReturns the size of a variable or typeC,C++
staticCreates permanent storage for a variableC,C++
static_castPerforms a non-polymorphic castC++
structDefines a new structureC,C++
switchExecutes code for different values of a variableC,C++
templateCreates generic functionsC++
thisPointer to the current objectC++
throwThrows an exceptionC++
trueThe boolean value of trueC++
tryExecutes a code that can throw an exceptionC++
typedefCreates a new type name from an existing typeC,C++
typeidDescribes an objectC++
typenameDeclares a class or undefined typeC++
unionStructure that assigns multiple variables to the same memory locationC,C++
unsignedDeclares an unsigned integer variableC,C++
usingImports complete or partial namespaces into the current scopeC++
virtualCreates a function that can be overridden by a derived classC++
voidDeclares functions or data with no associated data typeC,C++
volatileWarns the compiler about variables that can be modified unexpectedlyC,C++
wchar_tDeclares a wide-character variableC++
whileDeclares while loopC,C++


We hope it was clear to you. If you find it useful then do share it with your programming buddies and friends. Also if you have any doubt regarding any post do tell us in the comment section.

For daily updates do follow us on Instagram. Visit again!



Leave a Reply

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