C के Statements
In this page:
data_type variable_name = value; // declaration statement
variable_name = expression; // expression statement
function_name(arguments); // function call statement
Statement क्या है?
एक statement C में सबसे छोटी complete instruction है जिसे compiler execute कर सकता है, जैसे एक variable declare करना, एक function call करना, या एक expression evaluate करना, और एक C program मूल रूप से order में execute होने वाले statements का एक sequence है।
उदाहरण: What is a Statement?
// 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;
// Print formatted text to the screen
printf("%d", x);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Expression Statements
एक expression statement एक expression से बनता है, जैसे एक assignment या एक function call, जिसके बाद एक semicolon आता है, और यह statement की सबसे common किस्म है, जो सिर्फ अपने side effect के लिए execute होती है।
उदाहरण: Expression Statements
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
int x;
x = 5 + 3;
// Print formatted text to the screen
printf("%d", x);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Compound Statements (Blocks)
एक compound statement, या block, कई statements को curly braces के अंदर एक साथ group करता है, जिससे कई statements को एक single unit की तरह treat किया जा सकता है जहाँ भी language को सिर्फ एक statement चाहिए, जैसे किसी if या loop के अंदर।
उदाहरण: Compound Statements (Blocks)
// 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 > 0
if (x > 0) {
// Print formatted text to the screen
printf("Positive");
// Print formatted text to the screen
printf(", counted as one block");
}
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Declaration Statements
एक declaration statement एक नया variable (या function) introduce करता है, इसका type और name specify करते हुए, और optionally एक initial value, उस identifier को बाद के statements में इस्तेमाल के लिए available बनाते हुए।
उदाहरण: Declaration Statements
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare age and set it to 25
int age = 25;
// Print formatted text to the screen
printf("%d", age);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Semicolons से Statement Termination
braces में enclosed compound statements को छोड़कर, C का हर simple statement एक semicolon से terminate होना चाहिए, जो compiler को exactly बताता है कि एक instruction कहाँ खत्म होता है और अगला कहाँ शुरू होता है।
उदाहरण: Statement Termination with Semicolons
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare a and set it to 1
int a = 1;
// Declare b and set it to 2
int b = 2;
// Print formatted text to the screen
printf("%d", a + b);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
int x = 5जैसे statement के अंत में semicolon छोड़ देना, जो अगली line पर एक error cause करता है।if (x > 0);के बाद एक semicolon लगाना, जो empty statement को body बना देता है ताकि block हमेशा चले।{ }block के अंदर declared किसी variable को closing brace के बाद इस्तेमाल करना, जहाँ यह out of scope है।
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