YOUR C LEARNING COMPANION

Kahan se padhein?

Learning path
C ki buniyadChapter 10 of 73

C ko padhna: tokens, expressions aur statements

C ki line ke small language units pehchanein aur unhe declarations, expressions aur statements se jodein.

5 min readFoundationsC17 baseline
Offline reading
Is chapter mein8 sections
0% through this chapter

Poora program padhne se pehle uske chhote parts pehchaanein. C written characters ko tokens mein group karti hai, phir tokens se declarations, expressions aur statements banti hain. Isi tarah familiar punctuation ka precise meaning banta hai.

1. Tokens language ke units hain

C17 · illustrative fragment
int count = 3;
int total = count + 1;

Token preprocessing ke baad C source ka recognised piece hai. total jaisa poora naam ek token hai. == bhi ek token hai, chahe do characters hain. int total = count + 1; mein har naam, constant aur punctuator ka alag job hai.

C17 categoryExamplesRole
Keywordint, if, returnGrammatical roles wale reserved spellings
Identifiercount, totalEntity ka naam
Constant1, 2.5, 'A'Type aur value wala constant token
String literal"hello"Quoted character sequence, separate token category
Punctuator;, {, +, ==Structural symbols; kai operators bhi hain

“Operator” role batata hai, C17 list ki sixth lexical category nahi. + punctuator addition operator ka role nibha sakta hai. Preprocessing ki apni token rules hain, including preprocessing numbers; har intermediate token ko already-valid final C constant assume na karein.

2. Names rules ke andar choose hote hain

First portable names ke liye basic letters, digits aur underscores use karke letter se shuru karein. meal_count jaisa descriptive naam choose karein. C aur library kuch names reserve karti hain; sirf keywords avoid karna poora rule nahi. Wider characters ke version-specific requirements hain.

C17 · illustrative fragment
int score = 2;
int Score = 3;

C case distinguish karti hai, isliye yeh do objects ke do names hain. Example rule dikhata hai; names sirf capitalization se different rakhne ki recommendation nahi. main hosted startup ka special function name hai, lekin C keyword nahi. Familiar name pehchaanne se lexical category automatically nahi pata chalti.

3. Expression computation mein participate karti hai

Expression value compute, object ya function refer, ya side effects cause kar sakta hai. count + 1 value compute karta hai. count = 4 object change karta hai. Function call bhi expression hai. Kuch expressions ka type void hai aur ordinary result value nahi milti.

Symbol ko surrounding construct mein padhein. * expression mein multiplication kar sakta hai ya pointer declare karne mein help kar sakta hai. Parentheses expression group ya function call mark kar sakti hain. Shape pehchaanna shuruaat hai; context uska job batata hai.

4. Statements aur declarations alag block items hain

Expression ke baad semicolon se expression statement ban sakti hai: count = count + 1;. int count = 3; jaisi declaration ka role alag hai. C function blocks mein declarations aur statements dono allowed hain. Semicolon common hone se constructs same nahi ho jaate.

Compound statement braces se block items group karti hai. Braces initialization jaise other contexts mein bhi aati hain; “har brace function block start karti hai” reliable rule nahi. #include <stdio.h> preprocessing directive ka role phir alag hai; yeh ordinary statement nahi jiske end par semicolon add karna ho.

5. Formatting humans ki help karti hai, lekin kuch whitespace matter karti hai

Statement kai lines mein aa sakti hai aur ek line par kai statements ho sakti hain. Indentation person ko structure dikhati hai. Spaces tokens separate bhi karti hain: int count aur intcount different source hain. Literal ke andar spaces stored text ka part ho sakti hain.

Newlines preprocessing directives terminate karti hain, aur comment replacement aur line splicing translation rules se hote hain. Isliye formatting na “poori meaningful” hai na “poori irrelevant.” Consistent indentation aur spacing learner ko grammar-defined structure dekhne mein help karte hain.

Thoda sochkar dekhein

int total = count + 1; mein total keyword hai? Kya poori line expression statement hai?

Explanation padhein

Dono ka answer nahi. total identifier hai. Poori line initializer wali declaration hai; us initializer mein count + 1 expression hai.

Primary references aur aage ki reading

Aage badhne se pehle

  • C tokens recognise karke grammar ke according combine karti hai.
  • Expressions, declarations aur statements common punctuation ke bawajood different jobs karte hain.
  • Whitespace tokens separate kar sakti hai; literal ke spaces data bhi ho sakte hain.
In ideas ko alag rakhein
Token category / Operator role
+ jaisa punctuator operator ka role le sakta hai; lexical category aur grammatical job alag descriptions hain.
Apne words mein samjhaayein

int total = count + 1; ko poora expression kahe bina uske parts kaise alag karenge?

Optional: bolkar samjhein ya note rakhein. Tayyar hon toh aage badh sakte hain.

Apni understanding check karein

Optional hai. Answers save ya send nahi hote; chapter kabhi lock nahi hota.

= aur == alag tokens kyun hain?
Har choice ki explanation padhein
  1. Expressions mein = assignment aur == equality comparison karta hai.

    ✓ Sahi reasoning. Unke expression roles alag hain. = token initialization syntax mein bhi aata hai; wahan woh assignment expression nahi hota.

  2. Whitespace decide karta hai ki dono assignment mean karte hain.

    Whitespace in operators ko interchangeable nahi banata.

  3. Compiler programmer ke intention se meaning choose karta hai.

    Language ke token aur expression rules unke roles decide karte hain.

C17

Pehle edition ka quick reference

Yeh compact reference existing links aur saved passages ke liye retained hai. Full context ke liye upar ki expanded lesson padhein.

C source code tokens ki ek sequence se bana hota hai, jo language ki sabse chhoti meaningful units hoti hain. Primary token types yeh hain:

  • Keywords: Reserved words, jaise int, if aur return.
  • Identifiers: Objects, functions, types aur doosri entities ke naam.
  • Constants: Integer, floating, enumeration aur character constants, jaise 42, 3.14 aur 'A'.
  • String literals: "hello" jaise quoted character sequences; yeh alag token category hai.
  • Punctuators: ;, {, }, +, * aur && jaise symbols. Kai punctuators operators ka kaam karte hain; “operator” C17 mein separate lexical token category nahi hai.

Whitespace normally tokens ko separate karta hai aur translation mein har comment ek space se replace hota hai. Literals ke andar whitespace data hai; newline preprocessing directive ko end karti hai aur kuch macro definitions mein whitespace important hoti hai. Saare spaces ya comments delete karne se program unchanged rahega, aisa assume na karein.

Agla idea padhne ke liye tayyar?

Mark this chapter as read whenever you feel ready.

CHAPTER 10 / 73

Is chapter mein

C ko padhna: tokens, expressions aur statements

Search all 73 chapters in both languages.EN + HG

Try “pointer”, “why int”, or “undefined behavior”.

Concepts connect. Follow your curiosity.↑ ↓ to explore · Enter to open
MAKE YOURSELF COMFORTABLE

Your reading space

Appearance

A clear canvas with balanced contrast.

Text size

100%
AA

Reading tools

Your data stays in this browser

Export a backup before changing browsers or replacing an older version of the reader.

YOUR PERSONAL MARGINS

My notebook

Saved on this device
A LITTLE CLARITY

The glossary

A starting meaning, then a chapter to go deeper.

A QUICK DEFINITION

A little clarity

Read the full explanation →

A thought worth keeping