← Back to C Course | Chapter 1: Introduction & Basics | Lesson 6 of 21

C के Statements

एक statement सबसे छोटी complete instruction है जो C execute करता है, और एक C program मूल रूप से declaration, expression, और compound statements का एक sequence है जो order में execute होता है।
Syntax
c
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?

c
// 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;
}

Expression Statements

एक expression statement एक expression से बनता है, जैसे एक assignment या एक function call, जिसके बाद एक semicolon आता है, और यह statement की सबसे common किस्म है, जो सिर्फ अपने side effect के लिए execute होती है।

उदाहरण: Expression Statements

c
// 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;
}

Compound Statements (Blocks)

एक compound statement, या block, कई statements को curly braces के अंदर एक साथ group करता है, जिससे कई statements को एक single unit की तरह treat किया जा सकता है जहाँ भी language को सिर्फ एक statement चाहिए, जैसे किसी if या loop के अंदर।

उदाहरण: Compound Statements (Blocks)

c
// 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;
}

Declaration Statements

एक declaration statement एक नया variable (या function) introduce करता है, इसका type और name specify करते हुए, और optionally एक initial value, उस identifier को बाद के statements में इस्तेमाल के लिए available बनाते हुए।

उदाहरण: Declaration Statements

c
// 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;
}

Semicolons से Statement Termination

braces में enclosed compound statements को छोड़कर, C का हर simple statement एक semicolon से terminate होना चाहिए, जो compiler को exactly बताता है कि एक instruction कहाँ खत्म होता है और अगला कहाँ शुरू होता है।

उदाहरण: Statement Termination with Semicolons

c
// 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;
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. int x = 5 जैसे statement के अंत में semicolon छोड़ देना, जो अगली line पर एक error cause करता है।
  2. if (x > 0); के बाद एक semicolon लगाना, जो empty statement को body बना देता है ताकि block हमेशा चले।
  3. { } block के अंदर declared किसी variable को closing brace के बाद इस्तेमाल करना, जहाँ यह out of scope है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.