All content on this website, including dictionary, thesaurus, literature, geography, and other reference data is for informational purposes only.
- C Programming Tutorial
- C Programming useful Resources
- Selected Reading
An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. C language is rich in built-in operators and provides the following types of operators −
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
We will, in this chapter, look into the way each operator works.
Arithmetic Operators
The following table shows all the arithmetic operators supported by the C language. Assume variable A holds 10 and variable B holds 20 then −
Operator | Description | Example |
---|---|---|
+ | Adds two operands. | A + B = 30 |
− | Subtracts second operand from the first. | A − B = -10 |
* | Multiplies both operands. | A * B = 200 |
/ | Divides numerator by de-numerator. | B / A = 2 |
% | Modulus Operator and remainder of after an integer division. | B % A = 0 |
++ | Increment operator increases the integer value by one. | A++ = 11 |
-- | Decrement operator decreases the integer value by one. | A-- = 9 |
Relational Operators
The following table shows all the relational operators supported by C. Assume variable A holds 10 and variable B holds 20 then −
Operator | Description | Example |
---|---|---|
Checks if the values of two operands are equal or not. If yes, then the condition becomes true. | (A B) is not true. | |
!= | Checks if the values of two operands are equal or not. If the values are not equal, then the condition becomes true. | (A != B) is true. |
> | Checks if the value of left operand is greater than the value of right operand. If yes, then the condition becomes true. | (A > B) is not true. |
< | Checks if the value of left operand is less than the value of right operand. If yes, then the condition becomes true. | (A < B) is true. |
>= | Checks if the value of left operand is greater than or equal to the value of right operand. If yes, then the condition becomes true. | (A >= B) is not true. |
<= | Checks if the value of left operand is less than or equal to the value of right operand. If yes, then the condition becomes true. | (A <= B) is true. |
Logical Operators
Following table shows all the logical operators supported by C language. Assume variable A holds 1 and variable B holds 0, then −
Operator | Description | Example |
---|---|---|
&& | Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. | (A && B) is false. |
|| | Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true. | (A || B) is true. |
! | Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false. | !(A && B) is true. |
Bitwise Operators
Bitwise operator works on bits and perform bit-by-bit operation. The truth tables for &, |, and ^ is as follows −
p | q | p & q | p | q | p ^ q |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 0 |
1 | 0 | 0 | 1 | 1 |
Assume A = 60 and B = 13 in binary format, they will be as follows −
A = 0011 1100
B = 0000 1101
-----------------
A&B = 0000 1100
A|B = 0011 1101
A^B = 0011 0001
~A = 1100 0011
The following table lists the bitwise operators supported by C. Assume variable 'A' holds 60 and variable 'B' holds 13, then −
Operator | Description | Example |
---|---|---|
& | Binary AND Operator copies a bit to the result if it exists in both operands. | (A & B) = 12, i.e., 0000 1100 |
| | Binary OR Operator copies a bit if it exists in either operand. | (A | B) = 61, i.e., 0011 1101 |
^ | Binary XOR Operator copies the bit if it is set in one operand but not both. | (A ^ B) = 49, i.e., 0011 0001 |
~ | Binary One's Complement Operator is unary and has the effect of 'flipping' bits. | (~A ) = ~(60), i.e,. -0111101 |
<< | Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. | A << 2 = 240 i.e., 1111 0000 |
>> | Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. | A >> 2 = 15 i.e., 0000 1111 |
Assignment Operators
The following table lists the assignment operators supported by the C language −
Operator | Description | Example |
---|---|---|
= | Simple assignment operator. Assigns values from right side operands to left side operand | C = A + B will assign the value of A + B to C |
+= | Add AND assignment operator. It adds the right operand to the left operand and assign the result to the left operand. | C += A is equivalent to C = C + A |
-= | Subtract AND assignment operator. It subtracts the right operand from the left operand and assigns the result to the left operand. | C -= A is equivalent to C = C - A |
*= | Multiply AND assignment operator. It multiplies the right operand with the left operand and assigns the result to the left operand. | C *= A is equivalent to C = C * A |
/= | Divide AND assignment operator. It divides the left operand with the right operand and assigns the result to the left operand. | C /= A is equivalent to C = C / A |
%= | Modulus AND assignment operator. It takes modulus using two operands and assigns the result to the left operand. | C %= A is equivalent to C = C % A |
<<= | Left shift AND assignment operator. | C <<= 2 is same as C = C << 2 |
>>= | Right shift AND assignment operator. | C >>= 2 is same as C = C >> 2 |
&= | Bitwise AND assignment operator. | C &= 2 is same as C = C & 2 |
^= | Bitwise exclusive OR and assignment operator. | C ^= 2 is same as C = C ^ 2 |
|= | Bitwise inclusive OR and assignment operator. | C |= 2 is same as C = C | 2 |
Misc Operators ↦ sizeof & ternary
Besides the operators discussed above, there are a few other important operators including sizeof and ? : supported by the C Language.
Operator | Description | Example |
---|---|---|
sizeof() | Returns the size of a variable. | sizeof(a), where a is integer, will return 4. |
& | Returns the address of a variable. | &a; returns the actual address of the variable. |
* | Pointer to a variable. | *a; |
? : | Conditional Expression. | If Condition is true ? then value X : otherwise value Y |
Operators Precedence in C
Operator precedence determines the grouping of terms in an expression and decides how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has a higher precedence than the addition operator.
For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has a higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.
Here, operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom. Within an expression, higher precedence operators will be evaluated first.
Category | Operator | Associativity |
---|---|---|
Postfix | () [] -> . ++ - - | Left to right |
Unary | + - ! ~ ++ - - (type)* & sizeof | Right to left |
Multiplicative | * / % | Left to right |
Additive | + - | Left to right |
Shift | << >> | Left to right |
Relational | < <= > >= | Left to right |
Equality | != | Left to right |
Bitwise AND | & | Left to right |
Bitwise XOR | ^ | Left to right |
Bitwise OR | | | Left to right |
Logical AND | && | Left to right |
Logical OR | || | Left to right |
Conditional | ?: | Right to left |
Assignment | = += -= *= /= %=>>= <<= &= ^= |= | Right to left |
Comma | , | Left to right |
C | |
---|---|
C c | |
(See below) | |
Usage | |
Writing system | Latin script |
Type | Alphabetic |
Language of origin | Latin language |
Phonetic usage | [c] [k] [t͡ʃ] [t͡s(ʰ)] [d͡ʒ] [ʃ] [s̝] [ʕ] [ʔ] [θ] Others |
Unicode value | U+0043, U+0063 |
Alphabetical position | 3 Numerical value: 3 |
History | |
Development | |
Variations | (See below) |
Other | |
Associated numbers | 3 |
This article contains IPA phonetic symbols. Without proper rendering support, you may see question marks, boxes, or other symbols instead of Unicode characters. For an introductory guide on IPA symbols, see Help:IPA. |
|
C is the third letter in the English alphabet and a letter of the alphabets of many other writing systems which inherited it from the Latin alphabet. It is also the third letter of the ISO basic Latin alphabet. It is namedcee (pronounced /siː/) in English.[1]
- 3Use in writing systems
- 4Related characters
History
Phoenician gaml | Arabic ǧīm | Hebrew gimel | Greek Gamma | Etruscan C | Old Latin C (G) |
---|
'C' comes from the same letter as 'G'. The Semites named it gimel. The sign is possibly adapted from an Egyptian hieroglyph for a staff sling, which may have been the meaning of the name gimel. Another possibility is that it depicted a camel, the Semitic name for which was gamal. Barry B. Powell, a specialist in the history of writing, states 'It is hard to imagine how gimel = 'camel' can be derived from the picture of a camel (it may show his hump, or his head and neck!)'.[2]
In the Etruscan language, plosive consonants had no contrastive voicing, so the Greek 'Γ' (Gamma) was adopted into the Etruscan alphabet to represent /k/. Already in the Western Greek alphabet, Gamma first took a ' form in Early Etruscan, then ' in Classical Etruscan. In Latin it eventually took the 'c' form in Classical Latin. In the earliest Latin inscriptions, the letters 'c k q' were used to represent the sounds /k/ and /ɡ/ (which were not differentiated in writing). Of these, 'q' was used to represent /k/ or /ɡ/ before a rounded vowel, 'k' before 'a', and 'c' elsewhere.[3] During the 3rd century BC, a modified character was introduced for /ɡ/, and 'c' itself was retained for /k/. The use of 'c' (and its variant 'g') replaced most usages of 'k' and 'q'. Hence, in the classical period and after, 'g' was treated as the equivalent of Greek gamma, and 'c' as the equivalent of kappa; this shows in the romanization of Greek words, as in 'ΚΑΔΜΟΣ', 'ΚΥΡΟΣ', and 'ΦΩΚΙΣ' came into Latin as 'cadmvs', 'cyrvs' and 'phocis', respectively.
Other alphabets have letters homoglyphic to 'c' but not analogous in use and derivation, like the Cyrillic letter Es (С, с) which derives from the lunate sigma, named due to its resemblance to the crescent moon.
Later use
When the Roman alphabet was introduced into Britain, ⟨c⟩ represented only /k/, and this value of the letter has been retained in loanwords to all the insular Celtic languages: in Welsh, Irish, Gaelic, ⟨c⟩ represents only /k/. The Old English Latin-based writing system was learned from the Celts, apparently of Ireland; hence ⟨c⟩ in Old English also originally represented /k/; the Modern English words kin, break, broken, thick, and seek, all come from Old English words written with ⟨c⟩: cyn, brecan, brocen, þicc, and séoc. But during the course of the Old English period, /k/ before front vowels (/e/ and /i/) were palatalized, having changed by the tenth century to [tʃ], though ⟨c⟩ was still used, as in cir(i)ce, wrecc(e)a. On the continent, meanwhile, a similar phonetic change had also been going on (for example, in Italian).
In Vulgar Latin, /k/ became palatalized to [tʃ] in Italy and Dalmatia; in France and the Iberian peninsula, it became [ts]. Yet for these new sounds ⟨c⟩ was still used before the letters ⟨e⟩ and ⟨i⟩. The letter thus represented two distinct values. Subsequently, the Latin phoneme /kʷ/ (spelled ⟨qv⟩) de-labialized to /k/ meaning that the various Romance languages had /k/ before front vowels. In addition, Norman used the letter ⟨k⟩ so that the sound /k/ could be represented by either ⟨k⟩ or ⟨c⟩, the latter of which could represent either /k/ or /ts/ depending on whether it preceded a front vowel letter or not. The convention of using both ⟨c⟩ and ⟨k⟩ was applied to the writing of English after the Norman Conquest, causing a considerable re-spelling of the Old English words. Thus while Old English candel, clif, corn, crop, cú, remained unchanged, Cent, cæ´ᵹ (cé´ᵹ), cyng, brece, séoce, were now (without any change of sound) spelled 'Kent', 'keȝ', 'kyng', 'breke', and 'seoke'; even cniht ('knight') was subsequently changed to 'kniht' and þic ('thick') changed to 'thik' or 'thikk'. The Old English 'cw' was also at length displaced by the French 'qu' so that the Old English cwén ('queen') and cwic ('quick') became Middle English 'quen' 'quik', respectively. The sound [tʃ], to which Old English palatalized /k/ had advanced, also occurred in French, chiefly from Latin /k/ before 'a'. In French it was represented by the digraph ⟨ch⟩, as in champ (from Latin camp-um) and this spelling was introduced into English: the Hatton Gospels, written about 1160, have in Matt. i-iii, child, chyld, riche, mychel, for the cild, rice, mycel, of the Old English version whence they were copied. In these cases, the Old English ⟨c⟩ gave place to ⟨k qu ch⟩ but, on the other hand, ⟨c⟩ in its new value of /ts/ came in largely in French words like processiun, emperice, grace, and was also substituted for 'ts' in a few Old English words, as miltse, bletsien, in early Middle English milce, blecien. By the end of the thirteenth century both in France and England, this sound /ts/ de-affricated to /s/; and from that time ⟨c⟩ has represented /s/ before front vowels either for etymological reasons, as in lance, cent, or to avoid the ambiguity due to the 'etymological' use of ⟨s⟩ for /z/, as in ace, mice, once, pence, defence.
Thus, to show etymology, English spelling has advise, devise (instead of advize, devize), while advice, device, dice, ice, mice, twice, etc., do not reflect etymology; example has extended this to hence, pence, defence, etc., where there is no etymological reason for using ⟨c⟩. Former generations also wrote sence for sense. Hence, today the Romance languages and English have a common feature inherited from Vulgar Latin spelling conventions where ⟨c⟩ takes on either a 'hard' or 'soft' value depending on the following letter.
Use in writing systems
English
In English orthography, ⟨c⟩ generally represents the 'soft' value of /s/ before the letters ⟨e⟩ (including the Latin-derived digraphs ⟨ae⟩ and ⟨oe⟩, or the corresponding ligatures ⟨æ⟩ and ⟨œ⟩), ⟨i⟩, and ⟨y⟩, and a 'hard' value of /k/ before any other letters or at the end of a word. However, there are a number of exceptions in English: 'soccer' and 'Celt' are words that have /k/ where /s/ would be expected.
The 'soft' ⟨c⟩ may represent the /ʃ/ sound in the digraph ⟨ci⟩ when this precedes a vowel, as in the words 'delicious' and 'appreciate', and also in the word 'ocean' and its derivatives.
The digraph ⟨ch⟩ most commonly represents /tʃ/, but can also represent /k/ (mainly in words of Greek origin) or /ʃ/ (mainly in words of French origin). For some dialects of English, it may also represent /x/ in words like loch, while other speakers pronounce the final sound as /k/. The trigraph ⟨tch⟩ always represents /tʃ/.
The digraph ⟨ck⟩ is often used to represent the sound /k/ after short vowels.
Other languages
In the Romance languages French, Spanish, Italian, Romanian and Portuguese, ⟨c⟩ generally has a 'hard' value of /k/ and a 'soft' value whose pronunciation varies by language. In French, Portuguese, Catalan and Spanish from Latin America and southern Spain, the soft ⟨c⟩ value is /s/ as it is in English. In the Spanish spoken in northern and central Spain, the soft ⟨c⟩ is a voiceless dental fricative/θ/. In Italian and Romanian, the soft ⟨c⟩ is [t͡ʃ].
All Balto-Slavic languages that use the Latin alphabet, as well as Albanian, Hungarian, Pashto, several Sami languages, Esperanto, Ido, Interlingua, and Americanist phonetic notation (and those aboriginal languages of North America whose practical orthography derives from it) use ⟨c⟩ to represent /t͡s/, the voiceless alveolar or voiceless dental sibilant affricate. In Hanyu Pinyin, the standard romanization of Mandarin Chinese, the letter represents an aspirated version of this sound, /t͡sʰ/.
Among non-European languages that have adopted the Latin alphabet, ⟨c⟩ represents a variety of sounds. Yup'ik, Indonesian, Malay, and a number of African languages such as Hausa, Fula, and Manding share the soft Italian value of /t͡ʃ/. In Azeri, Crimean Tatar, Kurmanji Kurdish, and Turkish ⟨c⟩ stands for the voiced counterpart of this sound, the voiced postalveolar affricate/d͡ʒ/. In Yabem and similar languages, such as Bukawa, ⟨c⟩ stands for a glottal stop/ʔ/. Xhosa and Zulu use this letter to represent the click /ǀ/. In some other African languages, such as Berber languages, ⟨c⟩ is used for /ʃ/. In Fijian, ⟨c⟩ stands for a voiced dental fricative/ð/, while in Somali it has the value of /ʕ/.
The letter ⟨c⟩ is also used as a transliteration of Cyrillic ⟨ц⟩ in the Latin forms of Serbian, Macedonian, and sometimes Ukrainian, along with the digraph ⟨ts⟩.
Other systems
As a phonetic symbol, lowercase ⟨c⟩ is the International Phonetic Alphabet (IPA) and X-SAMPA symbol for the voiceless palatal plosive, and capital ⟨C⟩ is the X-SAMPA symbol for the voiceless palatal fricative.
Digraphs
There are several common digraphs with ⟨c⟩, the most common being ⟨ch⟩, which in some languages (such as German) is far more common than ⟨c⟩ alone. ⟨ch⟩ takes various values in other languages.
As in English, ⟨ck⟩, with the value /k/, is often used after short vowels in other Germanic languages such as German and Swedish (but some other Germanic languages use ⟨kk⟩ instead, such as Dutch and Norwegian). The digraph ⟨cz⟩ is found in Polish and ⟨cs⟩ in Hungarian, both representing /t͡ʃ/. The digraph ⟨sc⟩ represents /ʃ/ in Old English, Italian, and a few languages related to Italian (where this only happens before front vowels, while otherwise it represents /sk/). The trigraph ⟨sch⟩ represents /ʃ/ in German.
Related characters
Ancestors, descendants and siblings
- 𐤂 : Semitic letter Gimel, from which the following symbols originally derive
- Γ γ : Greek letter Gamma, from which C derives
- G g : Latin letter G, which is derived from Latin C
- Γ γ : Greek letter Gamma, from which C derives
- Phonetic alphabet symbols related to C:
- ɕ : Small c with curl
- ʗ : stretched C
- ᶜ : Modifier letter small c[4]
- ᶝ : Modifier letter small c with curl[4]
- ᴄ : Small capital c is used in the Uralic Phonetic Alphabet.[5]
- Ꞔ ꞔ : C with palatal hook, used for writing Mandarin Chinese using the early draft version of pinyin romanization during the mid-1950s[6]
C C Generals Zh Reborn V 5 0
Add to C with diacritics
- C with diacritics: Ć ćĈ ĉČ čĊ ċḈ ḉƇ ƈC̈ c̈Ȼ ȼÇ ç Ꞔ ꞔꞒ ꞓ
- Ↄ ↄ : Claudian letters[7]
Derived ligatures, abbreviations, signs and symbols
- © : copyright symbol
- ℃ : degree Celsius
- ¢ : cent
- ₡ : colón (currency)
- ₢ : Brazilian cruzeiro (currency)
- ₵ : Ghana cedi (currency)
- ₠ : European Currency Unit CE
- ℂ : double struck C
- ℭ : blackletter C
- Ꜿ ꜿ : Medieval abbreviation for Latin syllables con- and com-, Portuguese -us and -os[8]
Computing codes
Character | C | c | ||
---|---|---|---|---|
Unicode name | LATIN CAPITAL LETTER C | LATIN SMALL LETTER C | ||
Encodings | decimal | hex | decimal | hex |
Unicode | 67 | U+0043 | 99 | U+0063 |
UTF-8 | 67 | 43 | 99 | 63 |
Numeric character reference | C | C | c | c |
EBCDIC family | 195 | C3 | 131 | 83 |
ASCII1 | 67 | 43 | 99 | 63 |
- 1Also for encodings based on ASCII, including the DOS, Windows, ISO-8859 and Macintosh families of encodings.
Other representations
NATO phonetic | Morse code |
Charlie | –·–· |
Signal flag | Flag semaphore | American manual alphabet (ASLfingerspelling) | Braille dots-14 |
See also
- Speed of light, c
References
C C Generals Zh Patches
- ^'C' Oxford English Dictionary, 2nd edition (1989); Merriam-Webster's Third New International Dictionary of the English Language, Unabridged (1993); 'cee', op. cit.
- ^Powell, Barry B. (27 Mar 2009). Writing: Theory and History of the Technology of Civilization. Wiley Blackwell. p. 182. ISBN978-1405162562.
- ^Sihler, Andrew L. (1995). New Comparative Grammar of Greek and Latin (illustrated ed.). New York: Oxford University Press. p. 21. ISBN0-19-508345-8.
- ^ abConstable, Peter (2004-04-19). 'L2/04-132 Proposal to add additional phonetic characters to the UCS'(PDF).
- ^Everson, Michael; et al. (2002-03-20). 'L2/02-141: Uralic Phonetic Alphabet characters for the UCS'(PDF).
- ^West, Andrew; Chan, Eiso; Everson, Michael (2017-01-16). 'L2/17-013: Proposal to encode three uppercase Latin letters used in early Pinyin'(PDF).
- ^Everson, Michael (2005-08-12). 'L2/05-193R2: Proposal to add Claudian Latin letters to the UCS'(PDF).
- ^Everson, Michael; Baker, Peter; Emiliano, António; Grammel, Florian; Haugen, Odd Einar; Luft, Diana; Pedro, Susana; Schumacher, Gerd; Stötzner, Andreas (2006-01-30). 'L2/06-027: Proposal to add Medievalist characters to the UCS'(PDF).
External links
Wikisource has the text of the 1911 Encyclopædia Britannica article C. |
- Media related to C at Wikimedia Commons
- The dictionary definition of C at Wiktionary
- The dictionary definition of c at Wiktionary