C Keywords और Identifiers
In this page:
type identifier = value; // identifier: letters, digits, _ (no leading digit)
int count = 10; // int is a reserved keyword
Keywords
Keywords वे words हैं जिन्हें C language अपने syntax के लिए reserve करती है -- int, return, if, while, और लगभग 30 और -- और compiler इनमें से किसी को भी variable या function नाम की तरह इस्तेमाल करने की कोशिश को reject कर देगा।
उदाहरण: Keywords
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare x and set it to 5
int x = 5;
// Check whether x
if (x) {
// Send 0 back to the caller
return 0;
}
// Send 1 back to the caller
return 1;
}
Login to try C/C++/Java/PHP code in the editor
Identifiers
एक identifier आपके अपने code में किसी variable, function, या array के लिए चुना गया कोई भी नाम है। clear identifiers चुनना (जैसे x की बजाय totalPrice) आपके program को महीनों बाद या इसे review करने वाले किसी और के लिए पढ़ना कहीं आसान बना देता है।
उदाहरण: Identifiers
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare totalPrice and set it to 50
int totalPrice = 50;
// Print formatted text to the screen
printf("%d", totalPrice);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Naming Rules
C को हर identifier का एक letter या underscore से शुरू होना ज़रूरी है, और उसके बाद सिर्फ letters, digits, और underscores होने चाहिए -- 2total या total-price जैसे नाम compile नहीं होंगे क्योंकि वे इन rules को तोड़ते हैं।
उदाहरण: Naming Rules
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare _count and set it to 1
int _count = 1;
// Declare total2 and set it to 2
int total2 = 2;
// Print formatted text to the screen
printf("%d %d", _count, total2);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
नामों में Case Sensitivity
क्योंकि C case को significant मानता है, count और Count दो distinct identifiers हैं जो same scope में साथ exist कर सकते हैं -- subtle bugs का एक common source जब एक typo गलती से एक दूसरा, unintended variable introduce कर देता है।
उदाहरण: Case Sensitivity in Names
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare count and set it to 1
int count = 1;
// Declare Count and set it to 2
int Count = 2;
// Print formatted text to the screen
printf("%d %d", count, Count);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
नामों के लिए Best Practices
cryptic single letters पर studentAge जैसे descriptive multi-word names पसंद करें, i जैसे बहुत short-lived loop counters को छोड़कर, जहाँ convention अच्छे से समझी जाती है और brevity readability को नुकसान नहीं पहुंचाती।
उदाहरण: Best Practices for Names
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare studentAge and set it to 20
int studentAge = 20;
// Loop: repeat while the condition holds
for (int i = 0; i < 3; i++) {
// Print formatted text to the screen
printf("%d ", studentAge);
}
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
int for = 5;जैसे keyword को variable नाम की तरह इस्तेमाल करना, जो एक compile error है।1stValueजैसे किसी digit से identifier शुरू करना, जो allowed नहीं है।totalऔरTotalको मिला देना, क्योंकि identifiers case-sensitive हैं और अलग नाम हैं।
Chapter Quiz — Complete all 21 topics to unlock
0/21 topics done
Complete these topics first:
- C Introduction
- C History & Features
- C Environment Setup
- C First Program
- C Syntax & Structure
- C Statements
- C Comments
- C Keywords & Identifiers
- C Data Types
- C Character Data Type
- C Numeric Data Types
- C Decimal (Floating-Point) Numbers
- C sizeof Operator
- C Extended Data Types
- C Type Conversion
- C Booleans
- C Variables
- C Changing Variable Values
- C Multiple Variables
- C Constants
- C Fixed-Width Integers