C Basics

Understanding Basic Concepts of C Programming

Introduction to C (सी भाषा का परिचय)

C एक general-purpose programming language है जिसे 1972 में Dennis Ritchie ने develop किया था। यह structured programming का support करता है और system programming के लिए widely used है।

C is a general-purpose programming language developed by Dennis Ritchie in 1972. It supports structured programming and is widely used for system programming.

Key Features (मुख्य विशेषताएं):

  • C एक procedural language है
  • C is a procedural language
  • C low-level memory access provide करता है
  • C provides low-level memory access
  • C simple और efficient है
  • C is simple and efficient
  • C portable और flexible है
  • C is portable and flexible

Basic Structure (मूल संरचना)

C program की basic structure:

Basic structure of a C program:

#include <stdio.h>  // Header file inclusion

int main() {  // Main function
    printf("Hello, World!\n");  // Print statement
    return 0;  // Return statement
}
Component (कंपोनेंट) Description (विवरण)
Header Files Standard library functions को include करते हैं
Header Files Include standard library functions
Main Function Program execution का starting point है
Main Function Starting point of program execution
Statements Instructions जो program execute करता है
Statements Instructions that program executes

Variables and Constants (चर और स्थिरांक)

Variables और Constants का उपयोग:

Usage of Variables and Constants:

// Variable declaration and initialization
int age = 25;  // Integer variable
float pi = 3.14;  // Floating point variable
char grade = 'A';  // Character variable

// Constant declaration
const int MAX_VALUE = 100;  // Integer constant
const float PI = 3.14159;  // Floating point constant
  • Variables: Data store करने के लिए memory locations हैं
  • Variables: Memory locations to store data
  • Constants: Fixed values जो change नहीं हो सकते
  • Constants: Fixed values that cannot be changed
  • Data Types: Variables के type define करते हैं
  • Data Types: Define the type of variables
  • Input and Output (इनपुट और आउटपुट)

    Basic input/output operations:

    Basic input/output operations:

    #include <stdio.h>
    
    int main() {
        int number;
        
        // Input
        printf("Enter a number: ");
        scanf("%d", &number);
        
        // Output
        printf("You entered: %d\n", number);
        
        return 0;
    }
  • printf(): Output display करने के लिए use किया जाता है
  • printf(): Used to display output
  • scanf(): User input लेने के लिए use किया जाता है
  • scanf(): Used to take user input
  • Format Specifiers: Data type के according format define करते हैं
  • Format Specifiers: Define format according to data type
  • Best Practices (सर्वोत्तम प्रथाएं)

    C programming के साथ काम करने के best practices:

    Best practices for working with C programming:

  • Code Organization: Code को properly organize करें
  • Code Organization: Organize code properly
  • Comments: Code को document करने के लिए comments use करें
  • Comments: Use comments to document code
  • Naming Conventions: Meaningful names use करें
  • Naming Conventions: Use meaningful names
  • Error Handling: Proper error handling implement करें
  • Error Handling: Implement proper error handling